void Wrapper<Overkiz::UniversalUniqueIdentifier>::deserialize(Message::ConstIterator& iterator, Overkiz::UniversalUniqueIdentifier& val) const { std::string string; Wrapper<std::string> wstring; wstring.deserialize(iterator, string); val.build(string); }
void Wrapper<Overkiz::UniversalUniqueIdentifier>::serialize(Message::Iterator& iterator, const Overkiz::UniversalUniqueIdentifier& val) const { std::string string; val.get(string); Wrapper<std::string> wstring; wstring.serialize(iterator, string); }
void *Thread::ThreadCall(void *myWrapper) { Wrapper *wrapper = reinterpret_cast<Wrapper*>(myWrapper); wrapper->thread->mRunning = true; #ifdef PTW32_STATIC_LIB pthread_win32_thread_attach_np(); #endif try { wrapper->call(); } catch(const std::exception &e) { LogWarn("Thread::ThreadCall", String("Unhandled exception in thread: ") + e.what()); } catch(...) { LogWarn("Thread::ThreadCall", String("Unhandled unknown exception in thread")); } delete wrapper; wrapper->thread->mRunning = false; #ifdef PTW32_STATIC_LIB pthread_win32_thread_detach_np(); #endif pthread_exit(NULL); return NULL; }
void Wrapper<FileSystem::Directory>::serialize(Message::Iterator& iterator, const FileSystem::Directory & val) const { Wrapper<std::string> stringWrapper; Wrapper<uint32_t> uint32_tWrapper; stringWrapper.serialize(iterator, val.getName()); stringWrapper.serialize(iterator, val.getPath()); uint32_tWrapper.serialize(iterator, val.getMode()); }
qmlbind_backref qmlbind_value_get_backref(qmlbind_value self) { Wrapper *obj = dynamic_cast<Wrapper *>(self->toQObject()); if (!obj) { return 0; } return obj->backref().backref(); }
double CallBS(const Wrapper<Parameter>& r, const Wrapper<Parameter>& sig, double Expiry,double Spot, double Strike) { double d1,d2; d1=1./(sig->Mean(1,2)*sqrt(Expiry)) * ( log(Spot/Strike) + (r->Mean(1,2) + .5 * sig->Mean(1,2) * sig->Mean(1,2) ) * Expiry); d2=1./(sig->Mean(1,2)*sqrt(Expiry)) * ( log(Spot/Strike) + (r->Mean(1,2) - .5 * sig->Mean(1,2) * sig->Mean(1,2) ) * Expiry); double ans = CumulativeNormal(d1) * Spot - CumulativeNormal(d2) * Strike * exp(-r->Mean(1,2) * Expiry); return ans; }
js::UnwrapOneChecked(JSObject *obj, bool stopAtOuter) { if (!obj->isWrapper() || JS_UNLIKELY(!!obj->getClass()->ext.innerObject && stopAtOuter)) { return obj; } Wrapper *handler = Wrapper::wrapperHandler(obj); return handler->isSafeToUnwrap() ? Wrapper::wrappedObject(obj) : NULL; }
js::UnwrapOneChecked(RawObject obj) { // Checked unwraps should never unwrap outer windows. if (!obj->isWrapper() || JS_UNLIKELY(!!obj->getClass()->ext.innerObject)) { return obj; } Wrapper *handler = Wrapper::wrapperHandler(obj); return handler->isSafeToUnwrap() ? Wrapper::wrappedObject(obj) : NULL; }
int main() { int x = 7, y = 4; Wrapper<int> w = x; std::cout << x << " " << y << std::endl; w.t = 2; std::cout << x << " " << y << std::endl; w.rebind(y); std::cout << x << " " << y << std::endl; w.t = 14; std::cout << x << " " << y << std::endl; }
Ref<Object> Frame::unwrap(Frame * frame) { Object * function; frame->extract()(function, "function"); Wrapper * wrapper = ptr(function).as<Wrapper>(); if (wrapper) { return wrapper->value(); } else { return new(frame) Unwrapper(Cell::create(frame)(frame->sym("value"))(function)); } }
int main() { Wrapper<Foo> wrap; { std::cout << "before foo" << std::endl; wrap->foo(); std::cout << "after foo" << std::endl; } { std::cout << "before cfoo" << std::endl; wrap->cfoo(); std::cout << "after cfoo" << std::endl; } }
void Context::put(Control *control) { auto iter = std::find_if(m_controls.begin(), m_controls.end(), [control](Wrapper *w) { return w->control() == control; }); assert(iter != m_controls.end()); Wrapper *w = *iter; w->unref(); if (w->refCount() == 0) { m_controls.remove(w); m_plugin->hal()->put(w->control()); delete w; } }
void Wrapper<FileSystem::Directory>::deserialize(Message::ConstIterator& iterator, FileSystem::Directory & val) const { Wrapper<std::string> stringWrapper; Wrapper<uint32_t> uint32_tWrapper; std::string tmpString; uint32_t tmpUint32_t; stringWrapper.deserialize(iterator, tmpString); ++iterator; val.getName() = tmpString; stringWrapper.deserialize(iterator, tmpString); ++iterator; val.getPath() = tmpString; uint32_tWrapper.deserialize(iterator, tmpUint32_t); val.getMode() = tmpUint32_t; }
js::UnwrapObjectChecked(JSContext *cx, JSObject *obj) { while (obj->isWrapper() && !JS_UNLIKELY(!!obj->getClass()->ext.innerObject)) { JSObject *wrapper = obj; Wrapper *handler = Wrapper::wrapperHandler(obj); bool rvOnFailure; if (!handler->enter(cx, wrapper, JSID_VOID, Wrapper::PUNCTURE, &rvOnFailure)) return rvOnFailure ? obj : NULL; obj = Wrapper::wrappedObject(obj); JS_ASSERT(obj); } return obj; }
ExoticBSEngine::ExoticBSEngine(const Wrapper<PathDependent>& TheProduct_, const Parameters& R_, const Parameters& D_, const Parameters& Vol_, const Wrapper<RandomBase>& TheGenerator_, double Spot_) : ExoticEngine(TheProduct_,R_), TheGenerator(TheGenerator_) { MJArray Times(TheProduct_->GetLookAtTimes()); NumberOfTimes = Times.size(); TheGenerator->ResetDimensionality(NumberOfTimes); // Here is the place for change of models for different products Drifts.resize(NumberOfTimes); StandardDeviations.resize(NumberOfTimes); double Variance = Vol_.IntegralSquare(0,Times[0]); Drifts[0] = R_.Integral(0.0,Times[0]) - D_.Integral(0.0,Times[0]) - 0.5 * Variance; StandardDeviations[0] = sqrt(Variance); // here calculates the r*dt sigma*dw for (unsigned long j=1; j < NumberOfTimes; ++j) { double thisVariance = Vol_.IntegralSquare(Times[j-1],Times[j]); Drifts[j] = R_.Integral(Times[j-1],Times[j]) - D_.Integral(Times[j-1],Times[j]) - 0.5 * thisVariance; StandardDeviations[j] = sqrt(thisVariance); } LogSpot = log(Spot_); Variates.resize(NumberOfTimes); }
scoped_attributes_t( Wrapper& wrapper, attribute::set_t attributes, typename std::enable_if< !std::is_base_of<logger_base_t, Wrapper>::value >::type* = 0 ) : scoped_attributes_concept_t(wrapper.log()), m_guard_attributes(std::move(attributes)) {}
DT main(DT argc, char *argv[]) { //x.setRecalcFunc(); //y.setRecalcFunc(&recalcY); //z.setRecalcFunc(&recalcZ); /* a = 0 * b = 0 * a + b -> sum */ cout << "Init 1" << endl; Wrapper<DT> a = 0; Wrapper<DT> b = 0; DT sum = 0; cout << "Init 2" << endl; ptrA = &a; ptrB = &b; ptrSum = ∑ cout << "Init 3" << endl; a.onChange(&aChanged); b.onChange(&bChanged); cout << "Init 4" << endl; a = 7; b = 14; /* Wrapper<DT> x = a + b; Wrapper<DT> y = c - d; DT z = x * y; */ // 462 // 336 cout << "Init 5" << endl; cout << sum << endl; // gettimeofday(&startTime, 0); /*seconds = endTime.tv_sec - startTime.tv_sec; useconds = endTime.tv_usec - startTime.tv_usec; mtimeMT = ((seconds) * 1000 + useconds/1000.0) + 0.5;*/ }
void _3dsLoader::readObjectMaterial(Chunk ¤tChunk, Wrapper &model, Mesh *mesh) const { ASSERT(currentChunk.getID()==OBJECT_MATERIAL, "Expected chunk ID OBJECT_MATERIAL"); char materialName[255] = {0}; currentChunk.getString(materialName); mesh->material = model.getMaterial(materialName); // We don't care about shared vertices, so skip the rest }
ExoticBSEngineBB::ExoticBSEngineBB(const Wrapper<PathDependent>& TheProduct_, const Parameters& R_, const Parameters& D_, const Parameters& Vol_, const Wrapper<RandomBase>& TheGenerator_, double Spot_, bool speed_up_) : ExoticEngine(TheProduct_, R_, speed_up_), TheGenerator(TheGenerator_) { NumberOfTimes = TheProduct_->GetLookAtTimes().size(); if (speed_up == true) NumberOfTimes -= 1; times.resize(NumberOfTimes); out.resize(NumberOfTimes); for (unsigned long i(0); i < NumberOfTimes;++i) times[i] = TheProduct_->GetLookAtTimes()[i]; TheGenerator->ResetDimensionality(NumberOfTimes); Drifts.resize(NumberOfTimes); StandardDeviations.resize(NumberOfTimes); Drifts[0] = R_.Integral(0.0,times[0]) - D_.Integral(0.0,times[0]) - 0.5 * Vol_.IntegralSquare(0.0,times[0]); StandardDeviations[0] = sqrt(Vol_.IntegralSquare(0.0, times[0])); for (unsigned long j=1; j < NumberOfTimes; ++j) { Drifts[j] = R_.Integral(times[j-1],times[j]) - D_.Integral(times[j-1],times[j]) - 0.5 * Vol_.IntegralSquare(times[j-1],times[j]); StandardDeviations[j] = sqrt(Vol_.IntegralSquare(times[j - 1], times[j])); } LogSpot = std::log(Spot_); Variates.resize(NumberOfTimes); method_ = logscale; }
js::UnwrapOneChecked(JSContext *cx, JSObject *obj) { // Checked unwraps should never unwrap outer windows. if (!obj->isWrapper() || JS_UNLIKELY(!!obj->getClass()->ext.innerObject)) { return obj; } Wrapper *handler = Wrapper::wrapperHandler(obj); bool rvOnFailure; if (!handler->enter(cx, obj, JSID_VOID, Wrapper::PUNCTURE, &rvOnFailure)) { return rvOnFailure ? obj : NULL; } obj = Wrapper::wrappedObject(obj); JS_ASSERT(obj); return obj; }
File* open(CStrRef uri, CStrRef mode, CArrRef options) { const char *uri_string = uri.data(); Wrapper *wrapper = NULL; /* Special case for PHP4 Backward Compatability */ if (!strncasecmp(uri_string, "zlib:", sizeof("zlib:") - 1)) { wrapper = getWrapper("compress.zlib"); } else { const char *colon = strstr(uri_string, "://"); if (colon) { wrapper = getWrapper(String(uri_string, colon - uri_string, CopyString)); } } if (wrapper == NULL) { wrapper = getWrapper("file"); } assert(wrapper); return wrapper->open(uri, mode, options); }
void WrapperArray::optimize() { if(reserved.empty() == true) return; FactorialGenerator factorial(reserved.size()); shared_ptr<WrapperArray> minWrapperArray = nullptr; mutex mtx; //#pragma omp parallel for for (int i = 0; i < factorial.size(); i++) { shared_ptr<WrapperArray> wrapperArray(new WrapperArray(this->sample)); vector<size_t> &row = factorial[i]; for (size_t j = 0; j < row.size(); j++) { Product *product = this->reserved[row[j]]; if (wrapperArray->empty() == true || wrapperArray->at(wrapperArray->size() - 1)->tryInsert(product) == false) { Wrapper *wrapper = new Wrapper(*this->sample); wrapper->tryInsert(product); wrapperArray->emplace_back(wrapper); } } //unique_lock<mutex> uk(mtx); if (minWrapperArray == nullptr || wrapperArray->size() < minWrapperArray->size()) { minWrapperArray = wrapperArray; } } assign(minWrapperArray->begin(), minWrapperArray->end()); }
int main(int /*argc*/, const char ** /*argv*/) //************************************************************************************************************* { int result=0; AsyncProcessorEventHandler ThreadProcessorCallback; MyProcessor Processor; ProxyProcessor Proxy(Processor, "MyProxy"); Wrapper MyWrapper; MyWrapper.Start("Wrapper"); // Start the listener thread ThreadProcessorCallback.SetExecuteFunction(ProxyProcessor::Execute_CBFromProcessor, (void *)&Proxy); ThreadProcessorCallback.SetNotifFunction (Wrapper::SignalEvt , (void *)&MyWrapper); const unsigned int StackSize=1024; result=Proxy.Construct(PROTH_PRIORITY_NORMAL, StackSize, 50, sizeof(MyMsg), 50, sizeof(MyMsg), ThreadProcessorCallback); if(result != S_OK) { return(result); } // Processor.init(2, MyPorts, /*&myEventHandler, NULL*/ &Proxy, false /* is Invalid */); for (size_t nbWait=50; nbWait>0; --nbWait) { switch(global_state) { case OMX_StateIdle: Proxy.SetState(OMX_StateExecuting); break; case OMX_StateExecuting: Proxy.SetState(OMX_StateIdle); break; case State_WaitForResponse: case OMX_StateInvalid: default: break; } printf("\nmain %04d", nbWait); SleepMillisecond(100); } return(result); }
bool rtree_callback(Node* neighbour,void* w){ double h; double distance; Metric m; Node *individual,*parent; Wrapper* wrapper; wrapper = static_cast<Wrapper*>(w); individual = wrapper->get_individual(); parent = wrapper->get_parent(); h = individual->get_size(); m = individual->get_metric(); if(neighbour!=parent){ distance = infinity_distance(individual->get_point(),neighbour->get_point(),m); if(distance<k1*h){ wrapper->set_ok(0); return false; } } return true; }
void _3dsLoader::processObjectChunk(Chunk ¤tChunk, Wrapper &wrapper) const { ASSERT(currentChunk.getID()==OBJECT, "Expected chunk ID OBJECT"); Mesh *mesh = new Mesh; currentChunk.getString(mesh->m_strName); // set up a little trap to tell if an object material was encountered const string &trap = "FOOBARBARIAN"; mesh->material.setName(trap); processNextObjectChunk(currentChunk, wrapper, mesh); // if no material was loaded if(mesh->material.getName()==trap) { mesh->material = wrapper.getMostRecentMaterial(); } wrapper.model.push_back(mesh); }
bool check_wrapper() { Wrapper engine; if (VERBOSE) engine.setLogLevel("ERROR"); // engine.setSynchronous(false); engine.createGraph("graph0"); engine.createNode("graph0", "base.time.metro", "metro0"); engine.createNode("graph0", "base.flow.print", "print0"); engine.setNodeAttributeValue("graph0", "metro0", "interval", Message("i", 100)); engine.setNodeAttributeValue("graph0", "metro0", "running", Message("b", true)); if (! VERBOSE) engine.setNodeAttributeValue("graph0", "print0", "enabled", Message("b", false)); engine.connect("graph0", "metro0", "0", "print0", "0"); for (int i = 0; i < 10; ++i) { // engine.tick(); usleep(50 * 1000); // 50 ms } return true; }
std::string Wrapper<Overkiz::UniversalUniqueIdentifier>::signature() const { Wrapper<std::string> wstring; return wstring.signature(); }
static typename Wrapper::unwrap_type get(Wrapper &w) { return w.get(); }
void Filler::treat_region(GRegion* gr){ int NumSmooth = CTX::instance()->mesh.smoothCrossField; std::cout << "NumSmooth = " << NumSmooth << std::endl ; if(NumSmooth && (gr->dim() == 3)){ double scale = gr->bounds().diag()*1e-2; Frame_field::initRegion(gr,NumSmooth); Frame_field::saveCrossField("cross0.pos",scale); Frame_field::smoothRegion(gr,NumSmooth); Frame_field::saveCrossField("cross1.pos",scale); } #if defined(HAVE_RTREE) unsigned int i; int j; int count; int limit; bool ok2; double x,y,z; SPoint3 point; Node *node,*individual,*parent; MVertex* vertex; MElement* element; MElementOctree* octree; deMeshGRegion deleter; Wrapper wrapper; GFace* gf; std::queue<Node*> fifo; std::vector<Node*> spawns; std::vector<Node*> garbage; std::vector<MVertex*> boundary_vertices; std::set<MVertex*> temp; std::list<GFace*> faces; std::map<MVertex*,int> limits; std::set<MVertex*>::iterator it; std::list<GFace*>::iterator it2; std::map<MVertex*,int>::iterator it3; RTree<Node*,double,3,double> rtree; Frame_field::init_region(gr); Size_field::init_region(gr); Size_field::solve(gr); octree = new MElementOctree(gr->model()); garbage.clear(); boundary_vertices.clear(); temp.clear(); new_vertices.clear(); faces.clear(); limits.clear(); faces = gr->faces(); for(it2=faces.begin();it2!=faces.end();it2++){ gf = *it2; limit = code(gf->tag()); for(i=0;i<gf->getNumMeshElements();i++){ element = gf->getMeshElement(i); for(j=0;j<element->getNumVertices();j++){ vertex = element->getVertex(j); temp.insert(vertex); limits.insert(std::pair<MVertex*,int>(vertex,limit)); } } } /*for(i=0;i<gr->getNumMeshElements();i++){ element = gr->getMeshElement(i); for(j=0;j<element->getNumVertices();j++){ vertex = element->getVertex(j); temp.insert(vertex); } }*/ for(it=temp.begin();it!=temp.end();it++){ if((*it)->onWhat()->dim()==0){ boundary_vertices.push_back(*it); } } for(it=temp.begin();it!=temp.end();it++){ if((*it)->onWhat()->dim()==1){ boundary_vertices.push_back(*it); } } for(it=temp.begin();it!=temp.end();it++){ if((*it)->onWhat()->dim()==2){ boundary_vertices.push_back(*it); } } /*for(it=temp.begin();it!=temp.end();it++){ if((*it)->onWhat()->dim()<3){ boundary_vertices.push_back(*it); } }*/ //std::ofstream file("nodes.pos"); //file << "View \"test\" {\n"; for(i=0;i<boundary_vertices.size();i++){ x = boundary_vertices[i]->x(); y = boundary_vertices[i]->y(); z = boundary_vertices[i]->z(); node = new Node(SPoint3(x,y,z)); compute_parameters(node,gr); node->set_layer(0); it3 = limits.find(boundary_vertices[i]); node->set_limit(it3->second); rtree.Insert(node->min,node->max,node); fifo.push(node); //print_node(node,file); } count = 1; while(!fifo.empty()){ parent = fifo.front(); fifo.pop(); garbage.push_back(parent); if(parent->get_limit()!=-1 && parent->get_layer()>=parent->get_limit()){ continue; } spawns.clear(); spawns.resize(6); for(i=0;i<6;i++){ spawns[i] = new Node(); } create_spawns(gr,octree,parent,spawns); for(i=0;i<6;i++){ ok2 = 0; individual = spawns[i]; point = individual->get_point(); x = point.x(); y = point.y(); z = point.z(); if(inside_domain(octree,x,y,z)){ compute_parameters(individual,gr); individual->set_layer(parent->get_layer()+1); individual->set_limit(parent->get_limit()); if(far_from_boundary(octree,individual)){ wrapper.set_ok(1); wrapper.set_individual(individual); wrapper.set_parent(parent); rtree.Search(individual->min,individual->max,rtree_callback,&wrapper); if(wrapper.get_ok()){ fifo.push(individual); rtree.Insert(individual->min,individual->max,individual); vertex = new MVertex(x,y,z,gr,0); new_vertices.push_back(vertex); ok2 = 1; //print_segment(individual->get_point(),parent->get_point(),file); } } } if(!ok2) delete individual; } if(count%100==0){ printf("%d\n",count); } count++; } //file << "};\n"; int option = CTX::instance()->mesh.algo3d; CTX::instance()->mesh.algo3d = ALGO_3D_DELAUNAY; deleter(gr); std::vector<GRegion*> regions; regions.push_back(gr); meshGRegion mesher(regions); //? mesher(gr); //? MeshDelaunayVolume(regions); CTX::instance()->mesh.algo3d = option; for(i=0;i<garbage.size();i++) delete garbage[i]; for(i=0;i<new_vertices.size();i++) delete new_vertices[i]; new_vertices.clear(); delete octree; rtree.RemoveAll(); Size_field::clear(); Frame_field::clear(); #endif }
std::string Wrapper<FileSystem::Directory>::signature() const { Wrapper<std::string> stringWrapper; Wrapper<uint32_t> uint32_tWrapper; return (stringWrapper.signature() + stringWrapper.signature() + uint32_tWrapper.signature()); }