void objOffsetSet(TypedValue* base, CVarRef offset, TypedValue* val, bool validate /* = true */) { if (validate) { objArrayAccess(base); } static StringData* sd__offsetSet = StringData::GetStaticString("offsetSet"); ObjectData* obj = base->m_data.pobj; Instance* instance = static_cast<Instance*>(obj); const Func* method = instance->methodNamed(sd__offsetSet); ASSERT(method != NULL); TypedValue tvResult; tvWriteUninit(&tvResult); instance->invokeUserMethod(&tvResult, method, CREATE_VECTOR2(offset, tvAsCVarRef(val))); tvRefcountedDecRef(&tvResult); }
void Circuit::printInstance(CLayout* l, string instance){ Instance *currentInstance = l->getInstance(instance); if(!currentInstance) throw AstranError("Instance " + instance + " not found"); cout << "-> Instance: " << instance << " => " << currentInstance->getTargetCell() << endl; currentInstance->print(); cout << "-> Pins Assignment (Global Net->Pin): "; /* map<string, list<Net> >::iterator netList_it; for(netList_it=netList.begin(); netList_it!=netList.end(); netList_it++) for(tmp_it=netList_it->second.begin(); tmp_it!=netList_it->second.end(); tmp_it++) if(tmp_it->targetCellInst==instance) cout << " (" << netList_it->first << "->" << tmp_it->targetPin << ") "; cout << endl; */ }
//---------------------------------------------------------------------------------- // //---------------------------------------------------------------------------------- void EffectNodeTrack::Rendering(const Instance& instance, Manager* manager) { const InstanceValues& instValues = instance.rendererValues.track; TrackRenderer* renderer = manager->GetTrackRenderer(); if( renderer != NULL ) { float t = (float)instance.m_LivingTime / (float)instance.m_LivedTime; int32_t time = instance.m_LivingTime; int32_t livedTime = instance.m_LivedTime; SetValues( m_instanceParameter.ColorLeft, m_currentGroupValues.ColorLeft, TrackColorLeft, time, livedTime ); SetValues( m_instanceParameter.ColorCenter, m_currentGroupValues.ColorCenter, TrackColorCenter, time, livedTime ); SetValues( m_instanceParameter.ColorRight, m_currentGroupValues.ColorRight, TrackColorRight, time, livedTime ); SetValues( m_instanceParameter.ColorLeftMiddle, m_currentGroupValues.ColorLeftMiddle, TrackColorLeftMiddle, time, livedTime ); SetValues( m_instanceParameter.ColorCenterMiddle, m_currentGroupValues.ColorCenterMiddle, TrackColorCenterMiddle, time, livedTime ); SetValues( m_instanceParameter.ColorRightMiddle, m_currentGroupValues.ColorRightMiddle, TrackColorRightMiddle, time, livedTime ); SetValues( m_instanceParameter.SizeFor, m_currentGroupValues.SizeFor, TrackSizeFor, t ); SetValues( m_instanceParameter.SizeMiddle, m_currentGroupValues.SizeMiddle, TrackSizeMiddle, t ); SetValues( m_instanceParameter.SizeBack, m_currentGroupValues.SizeBack, TrackSizeBack, t ); m_instanceParameter.SRTMatrix43 = instance.GetGlobalMatrix43(); renderer->Rendering( m_nodeParameter, m_instanceParameter, m_userData ); m_instanceParameter.InstanceIndex++; } }
static void start_confd_upgrade_commit_end(void *ctxt) { auto *daemon = static_cast<ConfdDaemon*>(ctxt); Instance* inst = daemon->instance_; // did it fail? // ATTN: does not look to be a good place to update this state inst->update_dyn_state(RW_MGMT_SCHEMA_APPLICATION_STATE_READY); std::string log_str; RW_MA_INST_LOG(inst, InstanceCritInfo, (log_str="Upgrade commit complete. Schema version updated to = " + std::to_string(daemon->upgrade_ctxt_.schema_version_)).c_str()); return; }
//////////////////////////////////////////////////////////////// ///This function handles CMSG_GROUP_ACCEPT: //////////////////////////////////////////////////////////////// void WorldSession::HandleGroupAcceptOpcode(WorldPacket & recv_data) { CHECK_INWORLD_RETURN; // we are in group already if(_player->GetGroup() != NULL) return; Player* player = objmgr.GetPlayer(_player->GetInviter()); if(!player) return; player->SetInviter(0); _player->SetInviter(0); Group* grp = player->GetGroup(); if(grp != NULL) { grp->AddMember(_player->m_playerInfo); _player->iInstanceType = grp->m_difficulty; _player->SendDungeonDifficulty(); //sInstanceSavingManager.ResetSavedInstancesForPlayer(_player); return; } // If we're this far, it means we have no existing group, and have to make one. grp = new Group(true); grp->m_difficulty = static_cast<uint8>(player->iInstanceType); grp->AddMember(player->m_playerInfo); // add the inviter first, therefore he is the leader grp->AddMember(_player->m_playerInfo); // add us. _player->iInstanceType = grp->m_difficulty; _player->SendDungeonDifficulty(); Instance* instance = sInstanceMgr.GetInstanceByIds(player->GetMapId(), player->GetInstanceID()); if(instance != NULL && instance->m_creatorGuid == player->GetLowGUID()) { grp->m_instanceIds[instance->m_mapId][instance->m_difficulty] = instance->m_instanceId; instance->m_creatorGroup = grp->GetID(); instance->m_creatorGuid = 0; instance->SaveToDB(); } //sInstanceSavingManager.ResetSavedInstancesForPlayer(_player); // Currentgroup and all that shit are set by addmember. }
ThreadNetif::ThreadNetif(Instance &aInstance) : Netif(aInstance, OT_NETIF_INTERFACE_ID_THREAD) , mCoap(aInstance) #if OPENTHREAD_ENABLE_DHCP6_CLIENT , mDhcp6Client(aInstance) #endif // OPENTHREAD_ENABLE_DHCP6_CLIENT #if OPENTHREAD_ENABLE_DHCP6_SERVER , mDhcp6Server(aInstance) #endif // OPENTHREAD_ENABLE_DHCP6_SERVER #if OPENTHREAD_ENABLE_DNS_CLIENT , mDnsClient(aInstance.GetThreadNetif()) #endif // OPENTHREAD_ENABLE_DNS_CLIENT , mActiveDataset(aInstance) , mPendingDataset(aInstance) , mKeyManager(aInstance) , mLowpan(aInstance) , mMac(aInstance) , mMeshForwarder(aInstance) , mMleRouter(aInstance) #if OPENTHREAD_ENABLE_BORDER_ROUTER || OPENTHREAD_ENABLE_SERVICE , mNetworkDataLocal(aInstance) #endif , mNetworkDataLeader(aInstance) #if OPENTHREAD_FTD || OPENTHREAD_ENABLE_MTD_NETWORK_DIAGNOSTIC , mNetworkDiagnostic(aInstance) #endif , mIsUp(false) #if OPENTHREAD_ENABLE_BORDER_AGENT , mBorderAgent(aInstance) #endif #if OPENTHREAD_ENABLE_COMMISSIONER && OPENTHREAD_FTD , mCommissioner(aInstance) #endif // OPENTHREAD_ENABLE_COMMISSIONER && OPENTHREAD_FTD #if OPENTHREAD_ENABLE_DTLS , mDtls(aInstance) , mCoapSecure(aInstance) #endif #if OPENTHREAD_ENABLE_JOINER , mJoiner(aInstance) #endif // OPENTHREAD_ENABLE_JOINER #if OPENTHREAD_ENABLE_JAM_DETECTION , mJamDetector(aInstance) #endif // OPENTHREAD_ENABLE_JAM_DETECTTION #if OPENTHREAD_FTD , mJoinerRouter(aInstance) , mLeader(aInstance) , mAddressResolver(aInstance) #endif // OPENTHREAD_FTD , mChildSupervisor(aInstance) , mSupervisionListener(aInstance) , mAnnounceBegin(aInstance) , mPanIdQuery(aInstance) , mEnergyScan(aInstance) #if OPENTHREAD_CONFIG_ENABLE_TIME_SYNC , mTimeSync(aInstance) #endif { mCoap.SetInterceptor(&ThreadNetif::TmfFilter, this); }
void update_one_instance(const Instance& ins, double step_size) { size_t uid = ins.get_feature_group_index(0, 0); size_t iid = ins.get_feature_group_index(1, 0); size_t jid; double pred = predict(ins); for (size_t idx = 0; idx < num_neg_; ++ idx) { jid = sample_negative_item(uid); double pred_neg = predict_user_item_rating(uid, jid); double grad = loss_->gradient(pred - pred_neg, 1.); auto bigrad = grad + lambda_ * bi_(iid); auto bjgrad = -grad + lambda_ * bi_(jid); if (using_adagrad_) { bi_grad_(iid) += bigrad * bigrad; bi_grad_(jid) += bjgrad * bjgrad; bigrad /= std::sqrt(bi_grad_(iid)); bjgrad /= std::sqrt(bi_grad_(jid)); } bi_(iid) -= step_size * bigrad; bi_(jid) -= step_size * bjgrad; DVector x_grad = DVector::Zero(num_dim_); auto fit = user_rated_items_.find(uid); CHECK(fit != user_rated_items_.end()); double user_size = static_cast<double>(fit->second.size()); for (auto& kid : fit->second) { if (kid == iid) continue; DVector pj_grad = grad * (q_.row(iid) - q_.row(jid)) / std::pow((user_size - 1.), alpha_) + lambda_ * p_.row(kid); if (using_adagrad_) { p_grad_.row(kid) += pj_grad.cwiseProduct(pj_grad); for (size_t k = 0; k < num_dim_; ++k) pj_grad(k) = pj_grad(k) / std::sqrt(p_grad_(kid, k)); } p_.row(kid) -= step_size * pj_grad; x_grad += pj_grad; } DVector qi_grad = grad * (x_.row(uid) - p_.row(iid)) / std::pow((user_size - 1.), alpha_) + lambda_ * q_.row(iid); DVector qj_grad = - grad * (x_.row(uid) - p_.row(iid)) / std::pow((user_size - 1.), alpha_) + lambda_ * q_.row(jid); if (using_adagrad_) { q_grad_.row(iid) += qi_grad.cwiseProduct(qi_grad); q_grad_.row(jid) += qj_grad.cwiseProduct(qj_grad); for (size_t k = 0; k < num_dim_; ++k) { qi_grad(k) = qi_grad(k) / std::sqrt(q_grad_(iid, k)); qj_grad(k) = qj_grad(k) / std::sqrt(q_grad_(jid, k)); } } q_.row(iid) -= step_size * qi_grad; q_.row(jid) -= step_size * qj_grad; x_.row(uid) -= step_size * x_grad; } }
int main(int argc, const char * argv[]) { using namespace distributed_solver; // Add scenarios and path to store instances here... //int advertiser_dimensions [] = {1000}; //int impression_dimensions [] = {1000}; //long double bid_sparsity_scenario [] = {0.1}; //int advertiser_dimensions [] = {2}; //int impression_dimensions [] = {10}; //long double bid_sparsity_scenario [] = {0.5}; int advertiser_dimensions [] = {10000}; int impression_dimensions [] = {10000}; long double bid_sparsity_scenario [] = {0.001}; std::string file_name_path = "/Users/ciocan/Documents/Google/data/experiment_"; int num_iterations = 1000; long double epsilon = 0.05; long double numerical_accuracy_tolerance = 0.000000000000000001; for (int i = 0; i < (sizeof(advertiser_dimensions) / sizeof(int)); ++i) { for (int j = 0; j < (sizeof(impression_dimensions) / sizeof(int)); ++j) { for (int k = 0; k < (sizeof(bid_sparsity_scenario) / sizeof(long double)); ++k) { Instance inst = Instance(advertiser_dimensions[i], impression_dimensions[j], 1, bid_sparsity_scenario[k], epsilon, 0.25, numerical_accuracy_tolerance); inst.GenerateInstance(); // std::cout << file_name_path + "\n"; // inst.WriteInstanceToCSV(file_name_path); // inst.GenerateAndWriteInstance(file_name_path); // std::cout << "created global problem \n"; inst.RunMultiplicativeWeights(num_iterations, numerical_accuracy_tolerance); std::cout << "finished \n"; } } } return 0; }
NearestNodesList SpotSearch::findNearestTourNodes(const Instance& tour, unsigned int k) { NearestNodesList nearest; nearest.reserve(k); std::vector<double> dist; dist.reserve(k); double maxDist = 0.0; int tourIndex = 0; for (const auto& node : tour.getTour()) { std::vector<unsigned>* spots = nearestSpots[node.spot+1]; for (unsigned spotIndex : *spots) { // To avoid adding duplicate entries, only add pairs where first.spot < second.spot. if (node.spot > spotIndex) continue; // skip all spots that are not on the tour if (!tour.containsSpot(spotIndex)) continue; double spotDist = problem.getDistance(problem.getSpot(node.spot), problem.getSpot(spotIndex)); if (dist.size() >= k && spotDist >= maxDist) break; // We need to get the index of the node in the tour for the nearest spot unsigned nearestnode = tour.getNodeIndex(spotIndex); if (dist.size() >= k) { nearest.pop_back(); dist.pop_back(); } auto distIt = std::upper_bound(dist.begin(), dist.end(), spotDist); dist.insert(distIt, spotDist); nearest.insert(nearest.begin() + (distIt - dist.begin()), std::make_pair(tourIndex, nearestnode)); maxDist = dist.back(); } tourIndex++; } return nearest; }
Instance * readCCP::readSimpleTXT(QString name){ QString line; QStringList list; QList<Point*> pointsList; Instance * inst = new Instance; QFile file(name); if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) { qDebug() << "Can't open file: " + name; delete inst; return 0; } QTextStream input(&file); if (!input.atEnd()){ line = input.readLine(); list = line.split(":", QString::SkipEmptyParts); inst->setName(list[1].trimmed()); } if (!input.atEnd()){ line = input.readLine(); list = line.split(":", QString::SkipEmptyParts); inst->setCapacity(list[1].toDouble()); } if (!input.atEnd()){ line = input.readLine(); list = line.split(":", QString::SkipEmptyParts); inst->setNumCenters(list[1].toUShort()); } while (!input.atEnd()){ Point * p = new Point (inst); line = input.readLine(); list = line.split(":", QString::SkipEmptyParts); p->setDemand(list[3].toDouble()); p->setPosition(Position(list[1].toDouble(), list[2].toDouble())); pointsList.append(p); } Point ** points = new Point*[pointsList.size()]; for (unsigned short i = 0; i < pointsList.size() ; ++i){ points[i] = pointsList[i]; } inst->setPoints(points,pointsList.size()); return inst; }
void CompositionTest::deleteInstance_removes_dependant_connections() { Composition composition{new CompositionInstanceMock()}; Component *component = ComponentFactory::produce("Component", {"in"}, {"out"}); Instance *instance = InstanceFactory::produce(component, "Instance", Point(0,0)); composition.getInstances().add(instance); Connection *connection = ConnectionFactory::produce(instance->getPort("out"), instance->getPort("out")); composition.getConnections().add(connection); composition.getInstances().remove(instance); CPPUNIT_ASSERT_EQUAL(size_t(0), composition.getConnections().size()); ComponentFactory::dispose(component); CompositionFactory::cleanup(composition); }
Instance * Schedulable::addInstance(const string &nm, const Time & t, const Time & d, Channel * const chan) { Instance *i = new Instance(*this, nm, t, d, chan); addInstToList(i); if (uberQua && i) { // b = b->Sibling(3); // i->SetValue(b); i->Init(); uberQua->addToSchedule(i); // uberQua->display.CreateInstanceBridge(i); } else { cerr << "Schedulable: unexpected null while committing to schedule" << endl; } return i; }
int main(int argc, char ** argv){ // parse arguments if(argc != 4){ printf("usage: ./random problem_file execution_number num_iterations\n"); return -1; } const char * file_name = argv[file_name_idx]; int execution_number = atoi(argv[execution_idx]); long long num_processed = atoll(argv[num_processed_idx]); // read instance Instance instance = Instance::load(file_name); instance.preprocess(); int n = instance.num_words(); int best_known = instance.superstring_length(); int random_best = INT_MAX; int start = time(0); #pragma omp parallel for for(int i = 0; i < num_processed; i++){ Individual x(n); x.randomize(); int v = instance.evaluate(&x); #pragma omp critical { if(v < random_best) random_best = v; int duration = time(0) - start; printf("time = %d\nbest found = %d\nbest known = %d\n", duration, random_best, best_known); save_results(random_best, num_processed, duration, file_name, execution_number); } } int duration = time(0) - start; printf("time = %d\nbest found = %d\nbest known = %d\n", duration, random_best, best_known); save_results(random_best, num_processed, duration, file_name, execution_number); return 0; }
void InstanceMgr::_LoadInstances() { MapInfo * inf; Instance * in; QueryResult * result; // clear any instances that have expired. Log.Notice("InstanceMgr", "Deleting Expired Instances..."); CharacterDatabase.WaitExecute("DELETE FROM instances WHERE expiration <= %u", UNIXTIME); // load saved instances result = CharacterDatabase.Query("SELECT * FROM instances"); Log.Notice("InstanceMgr", "Loading %u saved instances." , result ? result->GetRowCount() : 0); if(result) { do { inf = WorldMapInfoStorage.LookupEntry(result->Fetch()[1].GetUInt32()); if(inf == NULL || result->Fetch()[1].GetUInt32() >= NUM_MAPS) { CharacterDatabase.Execute("DELETE FROM instances WHERE mapid = %u", result->Fetch()[1].GetUInt32()); continue; } in = new Instance(); in->m_mapInfo = inf; in->LoadFromDB(result->Fetch()); // this assumes that groups are already loaded at this point. if(in->m_creatorGroup && objmgr.GetGroupById(in->m_creatorGroup) == NULL) { delete in; continue; } if(m_instances[in->m_mapId] == NULL) m_instances[in->m_mapId] = new InstanceMap; m_instances[in->m_mapId]->insert( InstanceMap::value_type( in->m_instanceId, in ) ); } while(result->NextRow()); delete result; } }
void objOffsetUnset(TypedValue* base, CVarRef offset) { objArrayAccess(base); static StringData* sd__offsetUnset = StringData::GetStaticString("offsetUnset"); ObjectData* obj = base->m_data.pobj; if (LIKELY(obj->isInstance())) { Instance* instance = static_cast<Instance*>(obj); const Func* method = instance->methodNamed(sd__offsetUnset); ASSERT(method != NULL); TypedValue tv; tvWriteUninit(&tv); instance->invokeUserMethod(&tv, method, CREATE_VECTOR1(offset)); tvRefcountedDecRef(&tv); } else { tvAsVariant(base).getArrayAccess() ->o_invoke(sd__offsetUnset, CREATE_VECTOR1(offset)); } }
Instance* Instance::Clone(){ if(Archivable){ Instance* newGuy = cloneImpl(); if(newGuy == NULL){ return NULL; } for(std::vector<Instance*>::size_type i = 0; i != children.size(); i++){ Instance* kid = children[i]; if(kid != NULL){ Instance* kidClone = kid->Clone(); if(kidClone != NULL){ kidClone->setParent(newGuy); } } } } return NULL; }
int Instance::lua_GetChildren(lua_State* L){ Instance* inst = checkInstance(L, 1); if(inst){ lua_newtable(L); for(std::vector<Instance*>::size_type i = 0; i != inst->children.size(); i++){ Instance* kid = inst->children[i]; if(kid != NULL){ int lIndex = i + 1; //lua_pushnumber(L, lIndex); kid->wrap_lua(L); lua_rawseti(L, -2, lIndex); } } return 1; } return luaL_error(L, COLONERR, "GetChildren"); }
QQModel* osg::MetaQReflect_SwapBuffersOperation::createQQModel(const Instance*i){ //return new MetaQReflect_SwapBuffersOperation_QModel(i);} QMLSwapBuffersOperation *ret =new QMLSwapBuffersOperation(i); bool gencontextmenu=false; if(contextMenu.empty())gencontextmenu=true; if(gencontextmenu) contextMenu+= pmoc::MetaQQuickClass::getPartialContextMenu(*ret); { osg::GraphicsOperation *mother =dynamic_cast<osg::GraphicsOperation*>(ret->_model); Instance inst;inst.model=PMOCGETMETACLASS("osg::GraphicsOperation"); inst.ptr=reinterpret_cast<void*>(mother); if(!inst.isValid()){std::cerr<<"osg::GraphicsOperation model for osg::SwapBuffersOperationis invalid"<<std::endl;return ret;} pmoc::MetaQQuickClass *cl=PMOCGETMETACLASS("osg::GraphicsOperation"); if(!cl){std::cerr<<"osg::GraphicsOperation QQModel for osg::SwapBuffersOperationis not found"<<std::endl;return ret;} ret->_parentboxes[0]=cl->createQQModel(&inst); if(gencontextmenu) contextMenu+=cl->contextMenu; } return ret;}
QQModel* osg::MetaQReflect_LineSegment::createQQModel(Instance*i){ //return new MetaQReflect_LineSegment_QModel(i);} QMLLineSegment *ret =new QMLLineSegment(i); bool gencontextmenu=false; if(contextMenu.empty())gencontextmenu=true; if(gencontextmenu) contextMenu+= pmoc::MetaQQuickClass::getPartialContextMenu(*ret); { osg::Referenced *mother =dynamic_cast<osg::Referenced*>(ret->_model); Instance inst;inst.model=PMOCGETMETACLASS("osg::Referenced"); inst.ptr=reinterpret_cast<void*>(mother); if(!inst.isValid()){std::cerr<<"osg::Referenced model for osg::LineSegmentis invalid"<<std::endl;return ret;} pmoc::MetaQQuickClass *cl=PMOCGETMETACLASS("osg::Referenced"); if(!cl){std::cerr<<"osg::Referenced QQModel for osg::LineSegmentis not found"<<std::endl;return ret;} ret->_parentboxes[0]=cl->createQQModel(&inst); if(gencontextmenu) contextMenu+=cl->contextMenu; } return ret;}
void InstanceCtrl::OnInstDragged(InstanceCtrlEvent& event) { // No DnD in single column mode. if (GetWindowStyle() & wxINST_SINGLE_COLUMN) return; Instance *selectedInst = m_instList->GetSelectedInstance(); if (!selectedInst) return; wxTextDataObject instDataObj(selectedInst->GetInstID()); wxDropSource dragSource(instDataObj, this); dragSource.DoDragDrop(wxDrag_AllowMove); // Make sure we reset the group highlighting when the DnD operation is done. HighlightGroup(VisualCoord()); }
Instance *Instance::Init(void *aBuffer, size_t *aBufferSize) { Instance *instance = NULL; VerifyOrExit(aBufferSize != NULL); // Make sure the input buffer is big enough VerifyOrExit(sizeof(Instance) <= *aBufferSize, *aBufferSize = sizeof(Instance)); VerifyOrExit(aBuffer != NULL); instance = new (aBuffer) Instance(); instance->AfterInit(); exit: return instance; }
QQModel* osg::MetaQReflect_AnimationPathCallback::createQQModel(const Instance*i){ //return new MetaQReflect_AnimationPathCallback_QModel(i);} QMLAnimationPathCallback *ret =new QMLAnimationPathCallback(i); bool gencontextmenu=false; if(contextMenu.empty())gencontextmenu=true; if(gencontextmenu) contextMenu+= pmoc::MetaQQuickClass::getPartialContextMenu(*ret); { osg::NodeCallback *mother =dynamic_cast<osg::NodeCallback*>(ret->_model); Instance inst;inst.model=PMOCGETMETACLASS("osg::NodeCallback"); inst.ptr=reinterpret_cast<void*>(mother); if(!inst.isValid()){std::cerr<<"osg::NodeCallback model for osg::AnimationPathCallbackis invalid"<<std::endl;return ret;} pmoc::MetaQQuickClass *cl=PMOCGETMETACLASS("osg::NodeCallback"); if(!cl){std::cerr<<"osg::NodeCallback QQModel for osg::AnimationPathCallbackis not found"<<std::endl;return ret;} ret->_parentboxes[0]=cl->createQQModel(&inst); if(gencontextmenu) contextMenu+=cl->contextMenu; } return ret;}
void MatrixManager::report_install_cmd_res(uint64_t generation, bool ok) { ::sailor::ReadLocker instance_locker(&_instance_lock); for (std::map<std::string, Instance*>::iterator iter = _instance_list.begin(); iter != _instance_list.end(); ++ iter) { if (generation == iter->second->get_generation()) { Instance* slot = iter->second; if (ok) { slot->on_install(InstanceInfo::ErrorCode::SUCCESS); } else { slot->on_install(InstanceInfo::ErrorCode::DEPLOY_FAIL); } break; } } }
QQModel* osg::MetaQReflect_PrimitiveRestartIndex::createQQModel(const Instance*i){ //return new MetaQReflect_PrimitiveRestartIndex_QModel(i);} QMLPrimitiveRestartIndex *ret =new QMLPrimitiveRestartIndex(i); bool gencontextmenu=false; if(contextMenu.empty())gencontextmenu=true; if(gencontextmenu) contextMenu+= pmoc::MetaQQuickClass::getPartialContextMenu(*ret); { osg::StateAttribute *mother =dynamic_cast<osg::StateAttribute*>(ret->_model); Instance inst;inst.model=PMOCGETMETACLASS("osg::StateAttribute"); inst.ptr=reinterpret_cast<void*>(mother); if(!inst.isValid()){std::cerr<<"osg::StateAttribute model for osg::PrimitiveRestartIndexis invalid"<<std::endl;return ret;} pmoc::MetaQQuickClass *cl=PMOCGETMETACLASS("osg::StateAttribute"); if(!cl){std::cerr<<"osg::StateAttribute QQModel for osg::PrimitiveRestartIndexis not found"<<std::endl;return ret;} ret->_parentboxes[0]=cl->createQQModel(&inst); if(gencontextmenu) contextMenu+=cl->contextMenu; } return ret;}
QQModel* osgParticle::MetaQReflect_SectorPlacer::createQQModel(const Instance*i){ //return new MetaQReflect_SectorPlacer_QModel(i);} QMLSectorPlacer *ret =new QMLSectorPlacer(i); bool gencontextmenu=false; if(contextMenu.empty())gencontextmenu=true; if(gencontextmenu) contextMenu+= pmoc::MetaQQuickClass::getPartialContextMenu(*ret); { osgParticle::CenteredPlacer *mother =dynamic_cast<osgParticle::CenteredPlacer*>(ret->_model); Instance inst;inst.model=PMOCGETMETACLASS("osgParticle::CenteredPlacer"); inst.ptr=reinterpret_cast<void*>(mother); if(!inst.isValid()){std::cerr<<"osgParticle::CenteredPlacer model for osgParticle::SectorPlaceris invalid"<<std::endl;return ret;} pmoc::MetaQQuickClass *cl=PMOCGETMETACLASS("osgParticle::CenteredPlacer"); if(!cl){std::cerr<<"osgParticle::CenteredPlacer QQModel for osgParticle::SectorPlaceris not found"<<std::endl;return ret;} ret->_parentboxes[0]=cl->createQQModel(&inst); if(gencontextmenu) contextMenu+=cl->contextMenu; } return ret;}
InstanceImpl::InstanceImpl(const Instance& instance_descriptor): SessionBase{"FreeAX25_TCPServer::" + instance_descriptor.getName()}, m_instance_descriptor{ instance_descriptor }, m_broker{ m_pointer } { env().logInfo( "New FreeAX25_TCPServer::InstanceImpl(" + m_instance_descriptor.getName() + ")"); }
void InstanceMgr::_LoadInstances() { MapInfo * inf; Instance * in; QueryResult * result; // clear any instances that have expired. Log.Notice("InstanceMgr", "Deleting Expired Instances..."); CharacterDatabase.WaitExecute("DELETE FROM instances WHERE expiration <= %u", UNIXTIME); // load saved instances result = CharacterDatabase.Query("SELECT * FROM instances"); Log.Notice("InstanceMgr", "Loading %u saved instances." , result ? result->GetRowCount() : 0); if(result) { do { inf = WorldMapInfoStorage.LookupEntry(result->Fetch()[1].GetUInt32()); if(inf == NULL || result->Fetch()[1].GetUInt32() >= NUM_MAPS) { CharacterDatabase.Execute("DELETE FROM instances WHERE mapid = %u", result->Fetch()[1].GetUInt32()); continue; } in = new Instance(); in->m_mapInfo = inf; in->LoadFromDB(result->Fetch()); if(m_instances[in->m_mapId] == NULL) m_instances[in->m_mapId] = new InstanceMap; m_instances[in->m_mapId]->insert( InstanceMap::value_type( in->m_instanceId, in ) ); } while(result->NextRow()); DEBUG_LOG("InstanceMgr", "Loading %u saved instances." , result->GetRowCount()); delete result; } else DEBUG_LOG("InstanceMgr", "No saved instances found."); //reset the SavedInstanceId on expired instances. CharacterDatabase.WaitExecute("UPDATE groups LEFT JOIN instances ON groups.GroupInstanceID = instances.id SET groups.GroupInstanceID = 0 WHERE instances.id IS NULL;"); }
CallType runtimeObjectGetCallData(JSHTMLElement* element, CallData& callData) { // First, ask the plug-in view base for its runtime object. if (JSObject* scriptObject = pluginScriptObjectFromPluginViewBase(element)) { CallData scriptObjectCallData; if (scriptObject->methodTable()->getCallData(scriptObject, scriptObjectCallData) == CallTypeNone) return CallTypeNone; callData.native.function = callPlugin; return CallTypeHost; } Instance* instance = pluginInstance(element->impl()); if (!instance || !instance->supportsInvokeDefaultMethod()) return CallTypeNone; callData.native.function = callPlugin; return CallTypeHost; }
Instance* Layer::createInstance(Object* object, const ExactModelCoordinate& p, const std::string& id) { Location location(this); location.setExactLayerCoordinates(p); Instance* instance = new Instance(object, location, id); if(instance->isActive()) { setInstanceActivityStatus(instance, instance->isActive()); } m_instances.push_back(instance); m_instanceTree->addInstance(instance); std::vector<LayerChangeListener*>::iterator i = m_changeListeners.begin(); while (i != m_changeListeners.end()) { (*i)->onInstanceCreate(this, instance); ++i; } m_changed = true; return instance; }
void WebMediaPlayerProxy::invokeMethod(const String& methodName) { Frame* frame = element()->document()->frame(); RootObject *root = frame->script()->bindingRootObject(); if (!root) return; ExecState *exec = root->globalObject()->globalExec(); Instance* instance = pluginInstance().get(); if (!instance) return; instance->begin(); Class *aClass = instance->getClass(); Identifier iden(exec, methodName); MethodList methodList = aClass->methodsNamed(iden, instance); ArgList args; instance->invokeMethod(exec, methodList , args); instance->end(); }