本文整理汇总了C++中MetaObject类的典型用法代码示例。如果您正苦于以下问题:C++ MetaObject类的具体用法?C++ MetaObject怎么用?C++ MetaObject使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了MetaObject类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: runPy
PyObject*
Actionary::testCondition(iPAR* ipar, int which) {
char buf[MAXBUF];
char *argstr = new char[MAXBUF];
MetaObject *obj;
sprintf_s(argstr,MAXBUF,"%d",ipar->getAgent()->getID());
// strcpy_s(argstr, MAXBUF, singleQuote(ipar->getAgent()->getObjectName().c_str()));//Gets the agent from the instanced par
int num = ipar->par->getNumObjects();
//Finds all the objects the par requires to test it's condition
for (int i = 0; i < num; i++) {
strcat_s(argstr, MAXBUF, ", ");
obj=ipar->getObject(i);
if (obj != NULL)
sprintf_s(argstr,MAXBUF,"%s%d",argstr,obj->getID());
//strcat_s(argstr, MAXBUF, singleQuote(obj->getObjectName().c_str()));
else
sprintf_s(argstr,MAXBUF,"%s%d",argstr,-1);
//strcat_s(argstr, MAXBUF, singleQuote(" "));
}
//Actually tests the condition
sprintf_s(buf, MAXBUF,"%s_%d.%s(%s)\n", ipar->par->getActionName().c_str(),ipar->getID(),conditionNames[which], argstr);
//debug("%s\n",buf);
delete [] argstr;
return runPy(buf);
}
示例2: while
//
// MetaTable::getObjectKeyAndType
//
// As above, but satisfying both conditions at once.
//
MetaObject *MetaTable::getObjectKeyAndType(const char *key, const MetaObject::Type *type) const
{
MetaObject *obj = nullptr;
while((obj = pImpl->keyhash.keyIterator(obj, key)))
{
if(obj->isInstanceOf(type))
break;
}
return obj;
}
示例3: countOfKeyAndType
//
// MetaTable::countOfKeyAndType
//
// As above, but satisfying both conditions at once.
//
int MetaTable::countOfKeyAndType(const char *key, const char *type)
{
MetaObject *obj = NULL;
int count = 0;
while((obj = pImpl->keyhash.keyIterator(obj, key)))
{
if(obj->isInstanceOf(type))
++count;
}
return count;
}
示例4: MetaKeyForIndex
//
// MetaTable::getObjectKeyAndType
//
// Overload taking a MetaObject interned key index and RTTIObject::Type
// instance.
//
MetaObject *MetaTable::getObjectKeyAndType(size_t keyIndex, const MetaObject::Type *type) const
{
metakey_t &keyObj = MetaKeyForIndex(keyIndex);
MetaObject *obj = nullptr;
while((obj = pImpl->keyhash.keyIterator(obj, keyObj.key, keyObj.unmodHC)))
{
if(obj->isInstanceOf(type))
break;
}
return obj;
}
示例5: while
//
// MetaTable::copyTableTo
//
// Adds copies of all objects in the source table to the destination table.
//
void MetaTable::copyTableTo(MetaTable *dest) const
{
MetaObject *srcobj = NULL;
// iterate on the source table
while((srcobj = tableIterator(srcobj)))
{
// create the new object
MetaObject *newObject = srcobj->clone();
// add the new object to the destination table
dest->addObject(newObject);
}
}
示例6: hasKeyAndType
//
// MetaTable::hasKeyAndType
//
// Returns true if an object exists in the table of both the specified key
// and type, and it is the same object. This is naturally slower as it must
// search down the key hash chain for a type match.
//
bool MetaTable::hasKeyAndType(const char *key, const char *type)
{
MetaObject *obj = NULL;
bool found = false;
while((obj = pImpl->keyhash.keyIterator(obj, key)))
{
// for each object that matches the key, test the type
if(obj->isInstanceOf(type))
{
found = true;
break;
}
}
return found;
}
示例7: assert
bool
AgentNet::readyToGo(iPAR* cfipar)
{
// is this the timing such that this ipar is ready to be executed?
double tempTime = cfipar->getStartTime();
if (tempTime <= partime->getCurrentTime()){
return true;
}
// if there is an object parameter, get the distance from the current agent location to this
// object. If the action isn't locomoting, then the agent will likely have to locomote to the object
// We will pop the action sooner to try to allow for the time it will take.
// We will always assume that the first object is the salient object.
if (cfipar->par->getNumObjects() > 0)
{
MetaObject* blah = cfipar->getObject(0);
if (blah != NULL)
{
MetaObject *obj = cfipar->getObject(0);
assert(obj);
par_debug("In AgentNet::readyToGo, object is %s\n",obj->getObjectName().c_str());
//Vector<3> *objPos = obj->getPosition();
std::string agentName = cfipar->getAgent()->getObjectName();
//MetaObject *agent = actionary->searchByNameObj(agentName);
//assert(agent);
/*Vector<3> *agtPos = agent->getPosition();
float dist;
dist = (objPos->v[0] - agtPos->v[0]) * (objPos->v[0] - agtPos->v[0]);
dist = dist + (objPos->v[1] - agtPos->v[1]) * (objPos->v[1] - agtPos->v[1]);
dist = dist + (objPos->v[2] - agtPos->v[2]) * (objPos->v[2] - agtPos->v[2]);
dist = sqrt(dist);*/
double adjustedTime = tempTime - getTimeToObject(cfipar->getAgent(), obj);
//(dist * 0.6897 * 10); // assuming walking speed of 1.45m/s
par_debug("Adjusted time is %f\n", adjustedTime);
if (adjustedTime <= partime->getCurrentTime())
return true;
}
}
return false;
}
示例8: string
int MetaSerializer::UnPack(const char* pszMetaName,Buffer & buffer,void * * ppObj)
{
*ppObj = NULL;
string typeName = string(pszMetaName);
MetaObject* msg = NewObject(typeName);
if(!msg)
{
LOG_ERROR("meta name = %s new fail !",typeName.c_str());
return -1;
}
if(!msg->ParseFromArray(buffer.pBuffer,buffer.iUsed))
{
LOG_ERROR("meta name = %s unpack error ! buffer sz = %d",typeName.c_str(),buffer.iUsed);
FreeObj(msg);
return -1;
}
*ppObj = msg;
return 0;
}
示例9: nError
void Nuria::RestfulHttpNode::registerAnnotatedHandlers () {
this->d_ptr->loaded = true;
if (!this->d_ptr->metaObject) {
this->d_ptr->metaObject = MetaObject::byName (metaObject ()->className ());
if (!this->d_ptr->metaObject) {
nError() << "Failed to auto-find meta object of class" << metaObject ()->className ();
return;
}
}
//
MetaObject *meta = this->d_ptr->metaObject;
for (int i = 0; i < meta->methodCount (); i++) {
MetaMethod method = meta->method (i);
registerMetaMethod (method);
}
}
示例10: MetaKeyForIndex
//
// MetaTable::getNextKeyAndType
//
// Overload taking a MetaObject interned key index.
//
MetaObject *MetaTable::getNextKeyAndType(MetaObject *object, size_t keyIdx, const char *type)
{
MetaObject *obj = object;
metakey_t &keyObj = MetaKeyForIndex(keyIdx);
if(object)
{
// As above, allow NULL in type to mean "same as current"
if(!type)
type = object->getClassName();
}
while((obj = pImpl->keyhash.keyIterator(obj, keyObj.key, keyObj.unmodHC)))
{
if(obj->isInstanceOf(type))
break;
}
return obj;
}
示例11: copy
void MetaObject::copy(const MetaObject& src, const MetaObject& dest) {
auto& props = dest.getProperties();
DY_OBJECTSERIALIZER_COPYLOOP(Integer);
DY_OBJECTSERIALIZER_COPYLOOP(IntegerArray);
DY_OBJECTSERIALIZER_COPYLOOP(Vector2);
DY_OBJECTSERIALIZER_COPYLOOP(Vector2Array);
DY_OBJECTSERIALIZER_COPYLOOP(Vector3);
DY_OBJECTSERIALIZER_COPYLOOP(Vector3Array);
DY_OBJECTSERIALIZER_COPYLOOP(Vector4);
DY_OBJECTSERIALIZER_COPYLOOP(Vector4Array);
DY_OBJECTSERIALIZER_COPYLOOP(Float);
DY_OBJECTSERIALIZER_COPYLOOP(FloatArray);
DY_OBJECTSERIALIZER_COPYLOOP(Color);
DY_OBJECTSERIALIZER_COPYLOOP(ColorArray);
DY_OBJECTSERIALIZER_COPYLOOP(String);
DY_OBJECTSERIALIZER_COPYLOOP(StringArray);
DY_OBJECTSERIALIZER_COPYLOOP(Boolean);
DY_OBJECTSERIALIZER_COPYLOOP(BooleanArray);
}
示例12: main
int main(void){
partime = new parTime(); // setup the timing info for the simulation
partime->setTimeOffset(8,30,30); // hours, minutes, seconds from midnight
partime->setTimeRate(1); // how fast should time change
// Create an Actionary
actionary=new Actionary();
actionary->init();
MetaObject* object = new MetaObject("Sink_0"); // Creates a single Sink object
// Give the object a position of 8,1,2
Vector<3> *pos=new Vector<3>();
pos->v[0]=8.0f;
pos->v[1]=1.0f;
pos->v[2]=2.0f;
object->setPosition(pos);
// Check to see what actions are associated with a sink
std::cout << "The sink can be cleaned (true or false)? " << object->searchAffordance(actionary->searchByNameAct("Clean"),0) << std::endl;
std::cout << "The sink can be eaten (true or false)? " << object->searchAffordance(actionary->searchByNameAct("Eat"),0) << std::endl;
//Allows the object to clean
std::cout << "The sink can be cleaned (true or false)? " << object->searchAffordance(actionary->searchByNameAct("Clean"),1) << std::endl;
actionary->addAffordance(actionary->searchByNameAct("Clean"),object,1);
std::cout << "The sink can be cleaned (true or false)? " << object->searchAffordance(actionary->searchByNameAct("Clean"),1) << std::endl;
//Creates a new object, and adds the sink to it's contents
MetaObject* container= new MetaObject("Bookshelf_large");
container->addContents(object);
//Checks to see if the object is in the contents of the container (physcially) and the possession (mentally)
std::cout<<"The sink is physically in the bookshelf(true or false)? "<<container->searchContents("Sink_0")<<std::endl;
std::cout<<"The sink is owned by the bookshelf(true or false)? "<<container->searchPossession("Sink_0")<<std::endl;
system("PAUSE");
}
示例13: lock
void GwObjectHost::harvestServiceOriginatingObjects(Message& msg, TransportSocketPtr sender)
{
Signature signature;
{
boost::upgrade_lock<boost::shared_mutex> lock(_mutex);
MetaObject* metaObject = NULL;
const Signature& (MetaMethod::*signatureGetter)() const = NULL;
if (msg.type() == Message::Type_Reply || msg.type() == Message::Type_Error)
{
std::map<ServiceId, std::map<ObjectId, MetaObject> >::iterator sit = _servicesMetaObjects.find(msg.service());
if (msg.function() == Message::BoundObjectFunction_MetaObject &&
sit->second.find(msg.object()) == sit->second.end())
{
boost::upgrade_to_unique_lock<boost::shared_mutex> unique_lock(lock);
_servicesMetaObjects[msg.service()][Message::GenericObject_Main] = extractReturnedMetaObject(msg, sender);
return;
}
metaObject = &_servicesMetaObjects[msg.service()][msg.object()];
signatureGetter = &MetaMethod::returnSignature;
}
else if (msg.type() == Message::Type_Call || msg.type() == Message::Type_Post)
{
// if a service does a CALL, he does so on a user-supplied object.
std::map<GwObjectId, MetaObject>::iterator mit = _objectsMetaObjects.find(msg.object());
assert(mit != _objectsMetaObjects.end());
metaObject = &mit->second;
signatureGetter = &MetaMethod::parametersSignature;
}
const MetaMethod* method = metaObject->method(msg.function());
if (!method)
return;
signature = (method->*signatureGetter)();
}
if (!hasObjectsSomewhere(signature))
{
// no object can be here
return;
}
AnyReference passed = msg.value(signature, sender);
StreamContext filler;
MockObjectHost host(Message::Service_Server);
Message dummy;
// we don't want to pollute the original message and potentially change valid id
// of contained objects, so we do it in an unrelated message.
dummy.setValue(passed, signature, &host, &filler);
const ObjectHost::ObjectMap& objects = host.objects();
std::map<ObjectId, MetaObject> newServicesMetaObject;
for (ObjectHost::ObjectMap::const_iterator it = objects.begin(), end = objects.end(); it != end; ++it)
{
ServiceBoundObject* sbo = static_cast<ServiceBoundObject*>(it->second.get());
RemoteObject* ro = static_cast<RemoteObject*>(sbo->object().asGenericObject()->value);
// We set an empty transportsocket.
// Otherwise when we destroy `passed` below, the remoteobject
// will attempt to send back home a `terminate` message, which we don't want.
// By setting a null socket the object will stay alive on the remote end.
ro->setTransportSocket(TransportSocketPtr());
newServicesMetaObject[ro->object()] = ro->metaObject();
}
{
boost::upgrade_lock<boost::shared_mutex> lock(_mutex);
boost::upgrade_to_unique_lock<boost::shared_mutex> unique_lock(lock);
_servicesMetaObjects[msg.service()].insert(newServicesMetaObject.begin(), newServicesMetaObject.end());
}
passed.destroy();
}
示例14:
string MetaSerializer::GetTypeName(void* obj)
{
MetaObject * msg = (MetaObject*)obj;
return msg->GetDescriptor()->name();
//return msg->GetTypeName();
}
示例15: is
bool is(void) const
{
return mo->self()->is_a(categorize_interface(
(Interface*)nullptr
));
}