//------------------------------------------------------------------------------
// entityStateManager() --  (Output support)
//    -- Update the entity object for this NIB(Player)
//------------------------------------------------------------------------------
bool Nib::entityStateManager(const double curExecTime)
{
   bool ok = true;
   if (getPlayer()->isMode(simulation::Player::ACTIVE) && isPlayerStateUpdateRequired(curExecTime)) {

      // Need to update this entity object ...

      NetIO* netIO = static_cast<NetIO*>(getNetIO());
      RTI::RTIambassador* rtiAmb = netIO->getRTIambassador();

      // ---
      // First, make sure this entity has been registered
      // ---
      if (!isRegistered()) {
         try {
            RTI::ObjectClassHandle theClassHandle = netIO->getObjectClassHandle( getClassIndex() );
            makeObjectName();
            setObjectHandle( rtiAmb->registerObjectInstance( theClassHandle, getObjectName() ) );
            netIO->addNibToObjectTables(this, simulation::NetIO::OUTPUT_NIB);
            std::cout << "rprfom::Nib::updateEntity(): Register entity: " << getObjectName() << " handle = " << getObjectHandle() << std::endl;
         }
         catch (RTI::Exception& e) {
            std::cerr << &e << std::endl;
            ok = false;
         }
      }

      // ---
      // Next, update the entity's attribute values ...
      // ---
      if ( ok && isRegistered()) {
         try {
            // Create the attribute-value pair set
            RTI::AttributeHandleValuePairSet* attrs = nullptr;
            attrs = RTI::AttributeSetFactory::create( NetIO::NUM_OBJECT_ATTRIBUTES );

            // Load the set with updated attribute values
            updateBasicEntity(attrs,curExecTime);
            updatePhysicalEntity(attrs,curExecTime);
            updatePlatform(attrs,curExecTime);

            // Send attributes to the RTI
            //std::cout << "RprFom::Nib::updateEntity(): Update entity: " << getObjectName() << " handle = " << getObjectHandle() << std::endl;
            ok = netIO->updateAttributeValues(getObjectHandle(), attrs);

            delete attrs;
         }

         catch (RTI::Exception& e) {
            std::cerr << &e << std::endl;
            ok = false;
         }
      }
   } // end -- if active player needs an update

   return ok;
}
void EventDispatcher::dispatchEventToListeners(EventListenerVector* listeners, std::function<bool(EventListener*)> onEvent)
{
    bool shouldStopPropagation = false;
    auto fixedPriorityListeners = listeners->getFixedPriorityListeners();
    auto sceneGraphPriorityListeners = listeners->getSceneGraphPriorityListeners();
    
    ssize_t i = 0;
    // priority < 0
    if (fixedPriorityListeners)
    {
        bool isEmpty = fixedPriorityListeners->empty();
        for (; !isEmpty && i < listeners->getGt0Index(); ++i)
        {
            auto l = fixedPriorityListeners->at(i);
            if (!l->isPaused() && l->isRegistered() && onEvent(l))
            {
                shouldStopPropagation = true;
                break;
            }
        }
    }
    
    if (sceneGraphPriorityListeners)
    {
        if (!shouldStopPropagation)
        {
            // priority == 0, scene graph priority
            for (auto& l : *sceneGraphPriorityListeners)
            {
                if (!l->isPaused() && l->isRegistered() && onEvent(l))
                {
                    shouldStopPropagation = true;
                    break;
                }
            }
        }
    }

    if (fixedPriorityListeners)
    {
        if (!shouldStopPropagation)
        {
            // priority > 0
            ssize_t size = fixedPriorityListeners->size();
            for (; i < size; ++i)
            {
                auto l = fixedPriorityListeners->at(i);
                
                if (!l->isPaused() && l->isRegistered() && onEvent(l))
                {
                    shouldStopPropagation = true;
                    break;
                }
            }
        }
    }
}
//=============================================================================
// METHOD: SPELLvariableMonitor::retrieveLocalVariables()
//=============================================================================
void SPELLvariableMonitor::retrieveLocalVariables(std::vector<SPELLvarInfo>& vars)
{
	DEBUG("[VM] Retrieve Locals");

	/*
	 * Bottom stack frame is discarded,
	 * as globals and locals are the same dictionary
	 */
	if (m_frame->f_back == NULL) return;

	/*
	 * Get the names defined in the current code, including arguments
	 */
	std::vector<std::string> varNames = retrieveNames();

	/*
	 * Iterate over the locals dictionary, retrieving the names contained in
	 * varNames
	 */
	PyFrame_FastToLocals(m_frame);
	PyObject* dict = m_frame->f_locals;
	DEBUG("[VM] Frame: " + PYCREPR(m_frame));
	for( unsigned int index = 0; index< varNames.size(); index++)
	{
		std::string varName = varNames[index];
		PyObject* pyVarName = SSTRPY(varName);
		if (PyDict_Contains( dict, pyVarName ))
		{
			PyObject* object = PyDict_GetItem( dict, pyVarName );

			if (!SPELLpythonHelper::instance().isInstance(object, "Database", "spell.lib.adapter.databases.database"))
			{
				if (PyCallable_Check(object)) continue;
				if (PyClass_Check(object)) continue;
				if (PyModule_Check(object)) continue;
				if (PyInstance_Check(object)) continue;
			}
			DEBUG("[VM] Processing " + varName);
			std::string type = PYSSTR( PyObject_Type(object) );
			DEBUG("[VM] Type      : " + type);
			std::string value = PYREPR( object );
			DEBUG("[VM] Value     : " + value);
			DEBUG("[VM] Global    : " + BSTR(false));
			DEBUG("[VM] Registered: " + BSTR(isRegistered(varName)));

			// Mark empty values (empty strings) as "<empty>"
			if (value == "") value = EMPTY_STRING;

			vars.push_back( SPELLvarInfo(varName, type, value, false, isRegistered(varName)) );
		}
	}
	PyFrame_LocalsToFast(m_frame,0);
}
示例#4
0
IZ_BOOL AnimationStateMachine::removeBehaviour(
    AnimationStateMachineNode* from,
    AnimationStateMachineNode* to)
{
    IZ_BOOL result = IZ_FALSE;

    if (from && to) {
        IZ_ASSERT(isRegistered(from) && isRegistered(to));

        result = from->removeBehaviour(to);
    }

    return result;
}
void CityRegionImplementation::notifyLoadFromDatabase() {
	ManagedObjectImplementation::notifyLoadFromDatabase();

	if (cityRank == CityManager::CLIENT)
		return;

	if (cityRank < CityManager::TOWNSHIP) {
		citySpecialization = "";
	}

	Zone* zone = getZone();

	if (zone == NULL)
		return;

	zone->addCityRegionToUpdate(_this.get());

	if (isRegistered())
		zone->getPlanetManager()->addRegion(_this.get());

	//Add taxes if they dont exist.
	if (taxes.size() <= 0) {
		info("Adding taxes for existing city that had no taxes.", true);
		taxes.add(0);
		taxes.add(0);
		taxes.add(0);
		taxes.add(0);
		taxes.add(0);
	}
}
示例#6
0
AnimationStateMachineBehaviour* AnimationStateMachine::getBehaviour(
    AnimationStateMachineNode* from,
    AnimationStateMachineNode* to)
{
    AnimationStateMachineBehaviour* ret = nullptr;

    if (from && to) {
        IZ_ASSERT(isRegistered(from) && isRegistered(to));

        ret = from->getBehaviour(to);
    }

    IZ_ASSERT(ret);

    return ret;
}
示例#7
0
bool BaseChannel::registerObject(DBusError *error)
{
    if (isRegistered()) {
        return true;
    }

    QString name = uniqueName();
    QString busName = mPriv->connection->busName();
    //QString busName = QString(QLatin1String("%1.%2"))
    //        .arg(mPriv->connection->busName(),name);
    QString objectPath = QString(QLatin1String("%1/%2"))
                         .arg(mPriv->connection->objectPath(), name);
    debug() << "Registering channel: busName: " << busName << " objectName: " << objectPath;
    DBusError _error;

    debug() << "Channel: registering interfaces  at " << dbusObject();
    foreach(const AbstractChannelInterfacePtr & iface, mPriv->interfaces) {
        if (!iface->registerInterface(dbusObject())) {
            // lets not fail if an optional interface fails registering, lets warn only
            warning() << "Unable to register interface" << iface->interfaceName();
        }
    }

    bool ret = registerObject(busName, objectPath, &_error);
    if (!ret && error) {
        error->set(_error.name(), _error.message());
    }
    return ret;
}
示例#8
0
void Client::updateCounts(bool aRemove)
{
	// We always remove the count and then add the correct one if requested...
	if (m_countType != COUNT_UNCOUNTED)
	{
		--counts[m_countType];
		m_countType = COUNT_UNCOUNTED;
	}
	
	if (!aRemove)
	{
		if (isOp())
		{
			m_countType = COUNT_OP;
		}
		else if (isRegistered())
		{
			m_countType = COUNT_REGISTERED;
		}
		else
		{
			m_countType = COUNT_NORMAL;
		}
		++counts[m_countType];
	}
}
bool TOOL_MANAGER::runTool( TOOL_BASE* aTool )
{
    wxASSERT( aTool != NULL );

    if( !isRegistered( aTool ) )
    {
        wxASSERT_MSG( false, wxT( "You cannot run unregistered tools" ) );
        return false;
    }

    TOOL_ID id = aTool->GetId();

    if( aTool->GetType() == INTERACTIVE )
        static_cast<TOOL_INTERACTIVE*>( aTool )->resetTransitions();

    // If the tool is already active, bring it to the top of the active tools stack
    if( isActive( aTool ) )
    {
        m_activeTools.erase( std::find( m_activeTools.begin(), m_activeTools.end(), id ) );
        m_activeTools.push_front( id );
        return false;
    }

    setActiveState( m_toolIdIndex[id] );
    aTool->Reset( TOOL_INTERACTIVE::RUN );

    // Add the tool on the front of the processing queue (it gets events first)
    m_activeTools.push_front( id );

    return true;
}
示例#10
0
//____________________________________________________________________________________
void MdiWindowShadowFactory::unregisterWidget( QWidget* widget )
{
    if( !isRegistered( widget ) ) return;
    widget->removeEventFilter( this );
    _registeredWidgets.remove( widget );
    removeShadow( widget );
}
示例#11
0
bool SpriteComponent::setStaticSprite(hgeSprite* _staticSprite)
{
	// Do nothing if we are already using the supplied static mesh
	if (_staticSprite == m_pStaticSprite)
	{
		//TODO set up a log
		printf("Sprite already set up for static sprite component.\n");
		return false;
	}

	// Don't allow changing static meshes if "static" and registered
	AActor* Owner = getOwner();
	if (Owner != NULL && isRegistered())
	{
		printf("mesh changed failed because it is a static mesh or because it is already registered.\n");
		return false;
	}


	m_pStaticSprite = _staticSprite;

	// TODO: add streaming?

	// Since we have new mesh, we need to update bounds
	//UpdateBounds();
	return true;
}
bool TOOL_MANAGER::isActive( TOOL_BASE* aTool )
{
    if( !isRegistered( aTool ) )
        return false;

    // Just check if the tool is on the active tools stack
    return std::find( m_activeTools.begin(), m_activeTools.end(), aTool->GetId() ) != m_activeTools.end();
}
示例#13
0
DataBaseFactory *DataBaseRegistry::getFactoryById(const QString &id) {
    if(isRegistered(id)) {
        return factories[id];
    }
    else {
        return NULL;
    }
}
示例#14
0
IZ_BOOL AnimationStateMachine::removeNode(AnimationStateMachineNode* node)
{
    if (isRegistered(node)) {
        node->getListItem()->Leave();
        return IZ_TRUE;
    }

    return IZ_FALSE;
}
示例#15
0
文件: Model.cpp 项目: google/rysim
void Model::processEvent(const Event& event) {
    std::string target = event.getTarget();
    if (!isRegistered(agents_, target)) {
        LOG(FATAL) << "Attempted to process event [" << LoggingUtils::toString(event)
                   << "] for non-registered Agent, " << target;
    }
    dirtyAgents_.insert(target);
    agents_[target].processEvent(event);
}
示例#16
0
bool DataBaseRegistry::registerDataBase(DataBaseFactory *f, const QString &id) {
    if(!isRegistered(id)) {
        factories[id] = f;
        return true;
    }
    else {
        return false;
    }
}
void QDeclarativeBluetoothService::setServicePort(qint32 port)
{
    if(d->m_port != port){
        d->m_port = port;
        if(isRegistered())
            setRegistered(true);
        emit detailsChanged();
    }
}
示例#18
0
const void* IDManager::getObjectFromColor(tgt::col4 col) {
    if (col.a == 0)
        return 0;

    if (isRegistered(col))
        return colorToID_[col];
    else
        return 0;
}
示例#19
0
col4 IDManager::getColorFromObject(const void* obj) {
    if (obj == 0)
        return col4(0,0,0,0);

    if (isRegistered(obj))
        return IDToColor_[obj];
    else
        return col4(0,0,0,0);
}
void AbstractDBusInterface::updateValue(VariantType *property)
{
	if(mConnection == nullptr)
	{
		return;
	}

	if(isRegistered())
		signaller->fireSignal(mConnection, mObjectPath, mInterfaceName, "PropertiesChanged", property);
}
示例#21
0
void SceneComponent::onUnregister()
{
	if (isRegistered())
	{
		if (mParent != nullptr)
		{
			mParent->detachComponent(this);
		}
		Component::onUnregister();
	}
}
示例#22
0
文件: members.cpp 项目: dyfet/ccrtp
bool
MembershipBookkeeping::BYESource(uint32 ssrc)
{
    bool found = false;
    // If the source identified by ssrc is in the table, mark it
    // as leaving the session. If it was not, do nothing.
    if ( isRegistered(ssrc) ) {
        found = true;
        decreaseMembersCount(); // TODO really decrease right now?
    }
    return found;
}
  /**
     Get object state.
     @return current object state
  */
  state_t getState() const
  {
    if(isMapped())
      return STATE_CUDA_MAPPED;

    if(isBound())
      return STATE_GRAPHICS_BOUND;

    if(isRegistered())
      return STATE_INACTIVE;

    return STATE_UNUSED;
  }
void
ExeTraceInfo::removeTrace(void * exeTrace)
{
  ExeTrace *t = (ExeTrace*) exeTrace;
  if (!t)
    return;
  if (!isRegistered(t))
    return;

  exeTraces_.remove(t);
  free(t->describes_);
  free(t);
};
void RegisterPostMortemAction::readSettings(const QSettings *)
{
    Q_UNUSED(debuggerRegistryValueNameC); // avoid warning from MinGW

    bool registered = false;
    HKEY handle = 0;
    QString errorMessage;
    if (openRegistryKey(HKEY_LOCAL_MACHINE, debuggerRegistryKeyC, false, &handle, &errorMessage))
        registered = isRegistered(handle, debuggerCall(), &errorMessage);
    if (handle)
        RegCloseKey(handle);
    setValue(registered, false);
}
示例#26
0
TEST_F(PerformanceObserverTest, Observe) {
  V8TestingScope scope;
  initialize(scope.getScriptState());

  NonThrowableExceptionState exceptionState;
  PerformanceObserverInit options;
  Vector<String> entryTypeVec;
  entryTypeVec.append("mark");
  options.setEntryTypes(entryTypeVec);

  m_observer->observe(options, exceptionState);
  EXPECT_TRUE(isRegistered());
}
void LinkLocalServiceBrowser::stop() {
	assert(isRunning());
	if (isRegistered()) {
		unregisterService();
	}
	for (ResolveQueryMap::const_iterator i = resolveQueries.begin(); i != resolveQueries.end(); ++i) {
		i->second->stop();
	}
	resolveQueries.clear();
	services.clear();
	browseQuery->stopBrowsing();
	browseQuery.reset();
	onStopped(haveError);
}
示例#28
0
文件: Model.cpp 项目: google/rysim
bool Model::validateConnections(const Agents& agents) {
    for(Agents::const_iterator agentIter = agents.begin();
            agentIter != agents.end(); ++agentIter) {
        std::vector<std::string> connections = agentIter->second.getConnections();
        for(int connectionsIdx = 0; connectionsIdx < connections.size(); connectionsIdx++) {
            if (!isRegistered(agents, connections[connectionsIdx])) {
                LOG(ERROR) << "Agent connection list contained unregistered agent, "
                        << connections[connectionsIdx];
                return false;
            }
        }
    }
    return true;
}
示例#29
0
void InfluenceMap::recalculateInfluences(vector<T*> list){
	vector<T*>::iterator begin= list.begin(), end= list.end();
	for(;begin!=end;begin++)
	{
		int mask =isRegistered((*begin)->p);
		if(mask==0)continue;
		int range=(*begin)->getInfluenceRange();
		int x = (int)(*begin)->getX()/tileW;
		int y = (int)(*begin)->getY()/tileH;
		for(int i=max(x-range,0);i<min(x+range,w);i++)
			for(int j=max(y-range,0);j<min(y+range,h);j++)
				grid[i][j]|=mask;
	}
}
示例#30
0
TEST_F(PerformanceObserverTest, Disconnect) {
  V8TestingScope scope;
  initialize(scope.getScriptState());

  Persistent<PerformanceEntry> entry = PerformanceMark::create("m", 1234);
  EXPECT_EQ(0, numPerformanceEntries());

  m_observer->enqueuePerformanceEntry(*entry);
  EXPECT_EQ(1, numPerformanceEntries());

  m_observer->disconnect();
  EXPECT_FALSE(isRegistered());
  EXPECT_EQ(0, numPerformanceEntries());
}