void InfoControllerModifyEntity::unpack(PackedData& dp) { dp.get( fAction ); dp.get( fEntityId ); dp.get( fEntityType ); dp.get( fProfileId ); dp.get( fUserData ); }
// automatic unpacking, does simple data, need not be overloaded for simple cases void Info::unpack(PackedData& dp) { // we assume that the size of the structure comes first: unsigned infoSize; dp.get( infoSize ); Logger::debug3() << "Info: automatic unpacking of " << getInfoHandler().getClassType() << " with size=" << infoSize << std::endl; SMART_VERIFY( infoSize == getInfoHandler().getByteSize()-sizeof(Info) )(infoSize)(getInfoHandler().getByteSize())(sizeof(Info)); // now fill in the space appropriately dp.get_array(infoSize, reinterpret_cast<char*>(this)+sizeof(Info)); // get the data part from "dp" }
// automatic packing, does simple data correctly, need not be overloaded for simple cases void Info::pack(PackedData& dp) const { // get the size of the structure (w/o VMT): unsigned infoSize = getInfoHandler().getByteSize() - sizeof(Info); Logger::debug3() << "Info: automatic packing of " << getInfoHandler().getClassType() << " with size=" << infoSize << std::endl; SMART_ASSERT( infoSize>=0 ); // cast the object as a char array and skip the VMT stuff (everythig in Info): const char* data = reinterpret_cast<const char*>(this) + sizeof(Info); // cast it as a char array // and now put it into dp: dp.add( infoSize ); dp.add_array(infoSize, data); }
void PyInfo::unpack( PackedData& pd ) { #ifdef SIMX_USE_PRIME SMART_ASSERT(false) ("PyInfo::unpack() method must never get called when using SSF. Only PyRemoteInfo may be used"); #else //cout << "Inside unpack" << endl; fPickled = true; if(!pd.get( fPickledData )) assert( false); //pd.get(fData); //assert(pd.getAnything( fData )); /* // python::object pickler = python::import("cPickle"); string s; pd.get( s ); Logger::debug3() << "PyInfo: Inside unpack" << s << endl; // assert(s); //fData = pickler.attr("loads")(s); //fData = theInfoManager().getUnpacker()(s); python::object up = theInfoManager().getUnpacker(); assert(up); try { fData = up(s); } catch(...) { PyErr_Print(); PyErr_Clear(); } //string name = python::extract<string>( up.attr("__name__") ); //assert(o); //cout << name << endl;*/ #endif }
void PyRemoteInfo::unpack(PackedData& pd ) { if(!pd.get( fPickledData )) assert(false); #ifdef DEBUG Logger::debug3() << "PyRemoteInfo: Unpacked Pickled data is " << fPickledData << endl; #endif }
void PyRemoteInfo::pack( PackedData& pd ) const { //int debug_wait =1 ; //while(debug_wait); pd.add( fPickledData ); #ifdef DEBUG Logger::debug3() << "PyRemoteInfo: Packed Pickled data is " << fPickledData << endl; #endif }
void EventInfo::unpack(PackedData& dp) { //Logger::debug3() << "simx::EventInfo unpack" << *this << endl; dp.get(fDestEntity); int tmpInt; dp.get(tmpInt); fDestService = static_cast<ServiceAddress>(tmpInt); dp.get(fDelay); dp.get(fTime); // get the Info Info::ClassType type; dp.get(type); if( type!=Info::ClassType() ) { boost::shared_ptr<Info> info; theInfoManager().createInfo( type, info ); info->unpack(dp); fInfo = info; } else { Logger::error() << "EventInfo: no Info to unpack in " << *this << endl; } }
void PyInfo::pack( PackedData& pd ) const { #ifdef SIMX_USE_PRIME SMART_ASSERT(false) ("PyInfo::pack() method must never get called when using SSF. Only PyRemoteInfo may be used"); #else //cout << "inside pack" << endl; //std::ostringstream os; // save data to archive //boost::archive::text_oarchive oa(os); // write class instance to archive // assert(false); //oa << fData; //fData.serialize(oa,1);) //assert(false); // archive and stream closed when destructors are called //boost::python::str py_string = boost::python::pickle::dumps(fData); // python::object pickler = python::import("cPickle"); // python::str ps = python::extract<python::str> // (pickler.attr("dumps")(fData)); // python::str ps = //python::extract<python::str> // extract<str>( theInfoManager().getPacker()(fData) ); //string s = python::extract<string>(ps); //pd.add(s); //pd.addAnything(fData); //boost::python::str ps = dumps(fData); //pd.add(ps); //PyGILState_STATE gstate; //gstate = PyGILState_Ensure(); //Py_INCREF(fData.ptr()); //assert(fData.ptr()); pd.add( //python::extract<python::str> //(theInfoManager().getPacker()(*fData))); python::extract<string> (theInfoManager().getPacker()(getData()))); //pd.add( fPickledData ); //pd.add(theInfoManager().getPacker()(fData)); //PyGILState_Release(gstate); //pd.add( theInfoManager().getPacker()(fData) ); #endif }
void EventInfo::pack(PackedData& dp) const { dp.add(fDestEntity); dp.add( static_cast<int>(fDestService) ); dp.add(fDelay); dp.add(fTime); if( fInfo ) { dp.add( fInfo->getInfoHandler().getClassType() ); fInfo->pack( dp ); } else { dp.add( Info::ClassType() ); Logger::error() << "EventInfo: no Info to pack in " << *this << endl; } }