Пример #1
0
    void PyRegisterEntity( //const Entity::ClassType& name,
			   const python::object& py_entity_class) {
      
      Entity::ClassType ent_type;
      try {
	ent_type = python::extract<Entity::ClassType>
	  ( py_entity_class.attr("__name__"));
      }
      catch ( ... )
	{
	  PyErr_Print();
	  PyErr_Clear();
	  Logger::failure("PyRegister: Unable to register python entity");
	  return;
	}
      theEntityManager().registerPyEntity( ent_type, py_entity_class );
    }
Пример #2
0
    void PyEntity::sendPyInfo(const python::object& py_info,
					 const Time time,
					 const python::tuple& dest_ent,
					 const long dest_serv)
    {
      EntityID e_id = py2EntityId( dest_ent );
#ifdef SIMX_USE_PRIME
      if ( theEntityManager().findEntityLpId(e_id) !=
	   Control::getRank() )
	{
#ifdef DEBUG
	  Logger::debug3() << "PyEntity " << getId()
			   << " : Sending remotely, proceeding to pickle Python object" << endl;
#endif	  
	  boost::shared_ptr<PyRemoteInfo> info;
	  theInfoManager().createInfo( info );
	  if ( ! info->pickleData( py_info ) )
	    {
	      Logger::error() << "PyEntity " << getId()
			      << ": Error while pickling info. Not sending" << endl;
	      return;
	    }
	  else // succesful pickling, send it off
	    {
	      sendInfo( info, time, e_id, 
			static_cast<ServiceAddress>( dest_serv ) );
	    }
	}
      else // destination entity lives on the same LP. Use regular PyInfo for sending
	{
#ifdef DEBUG
	   Logger::debug3() << "PyEntity " << getId()
			    << " : Sending locally" << endl;
#endif
#endif
	  // either we are using SimEngine -- in which case sending local 
	  // and remote infos use the same procedure -- or
	  // we are using SSF and sending locally.


	   boost::shared_ptr<PyInfo> info;
	   theInfoManager().createInfo( info );
	   info->setData( py_info );
	   sendInfo( info, time, e_id, 
		     static_cast<ServiceAddress>( dest_serv ) );
#ifdef SIMX_USE_PRIME
	} //close-out else block
#endif
      
      //info->fData = boost::make_shared<boost::python::object>(py_info);
      


      // boost::shared_ptr<PyInfo> info;
      // theInfoManager().createInfo( info );
      // //info->fData = boost::make_shared<boost::python::object>(py_info);// py_info;
      // //info->fData = &py_info;
      // info->setData( py_info );
      // //processOutgoingInfo( info, time, e_id, 
      // //static_cast<ServiceAddress>( dest_serv ) );
      // sendInfo( info, time, e_id, static_cast<ServiceAddress>(dest_serv) );
    }