当前位置: 首页>>代码示例>>C++>>正文


C++ Create::getFrom方法代码示例

本文整理汇总了C++中Create::getFrom方法的典型用法代码示例。如果您正苦于以下问题:C++ Create::getFrom方法的具体用法?C++ Create::getFrom怎么用?C++ Create::getFrom使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Create的用法示例。


在下文中一共展示了Create::getFrom方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: testValues


//.........这里部分代码省略.........
    assert(obj->getClassNo() == Atlas::Objects::Entity::ACCOUNT_NO);
    assert(obj->getId() == "account");
    assert(obj->isDefaultId() == false);
    assert(obj->getName() == "");
    assert(obj->isDefaultName() == true);
    assert(obj->getParents().front() == "admin_entity");
    assert(obj->isDefaultParents() == false);
    assert(obj->getObjtype() == "class");
    assert(obj->isDefaultObjtype() == false);
    // assert(obj->getDescription() == "Base class for accounts");
    // assert(obj->isDefaultDescription() == false);
    }

    {
    Atlas::Message::MapType mobj;
    Root obj = Atlas::Objects::Factories::instance()->createObject(mobj);
    assert(obj->getClassNo() == Atlas::Objects::Entity::ANONYMOUS_NO);
    assert(obj->getId() == "");
    assert(obj->getName() == "");
    assert(obj->getParents().size() == 0);
    assert(obj->getObjtype() == "obj");
    // assert(obj->getDescription() == "");
    }

    {
    Atlas::Message::MapType mobj;
    mobj["id"] = std::string("bar");
    mobj["name"] = std::string("foo");
    Atlas::Message::ListType parents;
    parents.push_back(std::string("account"));
    mobj["parents"] = parents;
    Root obj = Atlas::Objects::Factories::instance()->createObject(mobj);
    assert(obj->getClassNo() == Atlas::Objects::Entity::ANONYMOUS_NO);
    assert(obj->getId() == "bar");
    assert(obj->getName() == "foo");
    assert(obj->getParents().front() == "account");
    assert(obj->getObjtype() == "obj");
    // assert(obj->getDescription() == "");
    }

    {
    Atlas::Message::MapType maccount;
    maccount["id"] = std::string("bar");
    maccount["name"] = std::string("foo");
    Atlas::Message::ListType parents;
    parents.push_back(std::string("player"));
    maccount["parents"] = parents;
    maccount["objtype"] = "obj";

    Atlas::Message::MapType mcreate;
    mcreate["from"] = std::string("bar");
    Atlas::Message::ListType parents2;
    parents2.push_back(std::string("create"));
    mcreate["parents"] = parents2;
    Atlas::Message::ListType args;
    args.push_back(maccount);
    mcreate["args"] = args;
    mcreate["objtype"] = "op";

    Create op = Atlas::Objects::smart_dynamic_cast<Create>(Atlas::Objects::Factories::instance()->createObject(mcreate));
    assert(op->getClassNo() == Atlas::Objects::Operation::CREATE_NO);
    assert(op->instanceOf(Atlas::Objects::Operation::CREATE_NO));
    assert(op->instanceOf(Atlas::Objects::Operation::ACTION_NO));
    assert(op->instanceOf(Atlas::Objects::ROOT_NO));
    assert(!op->instanceOf(Atlas::Objects::Operation::COMBINE_NO));
    assert(!op->instanceOf(Atlas::Objects::Entity::ACCOUNT_NO));
    assert(op->getFrom() == "bar");
    assert(op->getParents().size() == 1);
    assert(op->getParents().front() == "create");
    assert(op->getObjtype() == "op");
    // assert(op->getDescription() == 
           // "Create new things from nothing using this operator.");
    assert(op->getArgs().size() == 1);

    Account op_arg = (Account&)op->getArgs().front();
    assert(op_arg->getClassNo() == Atlas::Objects::Entity::PLAYER_NO);
    assert(!op_arg->instanceOf(Atlas::Objects::Operation::CREATE_NO));
    assert(!op_arg->instanceOf(Atlas::Objects::Operation::ACTION_NO));
    assert(op_arg->instanceOf(Atlas::Objects::ROOT_NO));
    assert(!op_arg->instanceOf(Atlas::Objects::Operation::COMBINE_NO));
    assert(op_arg->instanceOf(Atlas::Objects::Entity::ACCOUNT_NO));
    assert(op_arg->instanceOf(Atlas::Objects::Entity::PLAYER_NO));
    assert(op_arg->getId() == "bar");
    assert(op_arg->getParents().size() == 1);
    assert(op_arg->getParents().front() == "player");
    assert(op_arg->getObjtype() == "obj");
    // assert(op_arg->getDescription() == "Player accounts");
    assert(op_arg->getName() == "foo");
#if 0 //tmp
    assert(op_arg->hasAttr("password"));
    assert(op_arg->getAttr("password").isString());
    assert(op_arg->getAttr("password").asString() == "");
#endif
    assert(op_arg->hasAttr("name"));
    assert(!op_arg->hasAttr("foo"));
    assert(!op_arg->hasAttr("pos"));
    assert(!op_arg->isDefaultName());
    assert(op_arg->isDefaultPos());
    }
}
开发者ID:danniellecandys,项目名称:atlas-cpp,代码行数:101,代码来源:objects2.cpp


注:本文中的Create::getFrom方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。