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


C++ Create类代码示例

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


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

示例1: create_session_username

/// \brief Create a new account on the server
///
/// @param name User name of the new account
/// @param password Password of the new account
Root BaseClient::createSystemAccount()
{
    Anonymous player_ent;
    player_ent->setAttr("username", create_session_username());
    player_ent->setAttr("password", compose("%1%2", ::rand(), ::rand()));
    player_ent->setParents(std::list<std::string>(1, "sys"));
    
    Create createAccountOp;
    createAccountOp->setArgs1(player_ent);
    createAccountOp->setSerialno(m_connection.newSerialNo());
    send(createAccountOp);
    if (m_connection.wait() != 0) {
        std::cerr << "ERROR: Failed to log into server: \""
                  << m_connection.errorMessage() << "\""
                  << std::endl << std::flush;
        return Root(0);
    }

    const Root & ent = m_connection.getInfoReply();

    if (!ent->hasAttrFlag(Atlas::Objects::ID_FLAG)) {
        std::cerr << "ERROR: Logged in, but account has no id" << std::endl
                  << std::flush;
    } else {
        m_playerId = ent->getId();
        // m_playerName = name;
    }

    return ent;
}
开发者ID:erikogenvik,项目名称:cyphesis,代码行数:34,代码来源:BaseClient.cpp

示例2: processAccountCreate

void ClientConnection::processAccountCreate(const Create& cr)
{
    const std::vector<Root>& args = cr->getArgs();
    if (args.empty()) {
        sendError("missing account in create", cr);
        return;
    }
    
    // check for duplicate username
    AtlasAccount acc = smart_dynamic_cast<AtlasAccount>(args.front());
    if (!acc.isValid()) {
        sendError("malformed account in create", cr);
        return;
    }
    
    AccountMap::const_iterator A = m_server->findAccountByUsername(acc->getUsername());
    if (A  != m_server->m_accounts.end()) {
        sendError("duplicate account: " + acc->getUsername(), cr);
        return;
    }
    
    m_account = std::string("_") + acc->getUsername() + "_123";
    acc->setId(m_account);
    m_server->m_accounts[m_account] = acc;
    
    Info createInfo;
    createInfo->setArgs1(acc);
    createInfo->setTo(m_account);
    createInfo->setRefno(cr->getSerialno());
    send(createInfo);
    
    m_server->joinRoom(m_account, "_lobby");
    m_server->resetWorld();
}
开发者ID:danniellecandys,项目名称:eris,代码行数:34,代码来源:clientConnection.cpp

示例3: main

int main()
{
    cout << "\n";
    
    Create create;
    Change change;
    
    create.fillPointerBuffer();

    cout << "main()---------------------------------" << endl;
    //cout << "create.num:     " << create.num << endl;
    cout << "create.bufferPtr:  " << create.bufferPtr << endl;
    cout << "change.process(create.bufferPtr, create.size)" << endl;
    cout << "---------------------------------------" << endl;
    cout << "\n";
    
    change.process(create.bufferPtr, create.size);
    
    cout << "\n";
    cout << "main()---------------------------------" << endl;
    cout << "create.bufferPtr:  " << create.bufferPtr << endl;
    cout << "create.size: " << create.size << endl;
    cout << "---------------------------------------" << endl;
    cout << "\n";
    cout << "----------SUMMARY-------------" << endl;
    cout << "create.bufferPtr: " << create.bufferPtr << endl;
    cout << "create.size: " << create.size << endl;
    for (int i=0; i<create.size; i++) {
        cout << "create.bufferPtr[" << i << "]: " << create.bufferPtr[i] << endl;
    }
    cout << "------------------------------" << endl;
    cout << "\n";
    
    return 0;
}
开发者ID:MeOwen,项目名称:sogm_opdrachten,代码行数:35,代码来源:main.cpp

示例4: test_CreateOperation_root_arg

void Connectiontest::test_CreateOperation_root_arg()
{
    Create op;
    OpVector res;
    op->setArgs1(Root());
    m_connection->operation(op, res);
    ASSERT_EQUAL(m_connection->m_objects.size(), 0u);
    ASSERT_TRUE(Router_error_called);
}
开发者ID:9cat,项目名称:cyphesis,代码行数:9,代码来源:Connectiontest.cpp

示例5: test_CreateOperation_empty_arg

void Connectiontest::test_CreateOperation_empty_arg()
{
    Create op;
    OpVector res;
    restricted_flag = false;
    Anonymous op_arg;
    op->setArgs1(op_arg);
    m_connection->operation(op, res);
    ASSERT_EQUAL(m_connection->m_objects.size(), 0u);
    ASSERT_TRUE(Router_error_called);
}
开发者ID:9cat,项目名称:cyphesis,代码行数:11,代码来源:Connectiontest.cpp

示例6: test_CreateOperation_account_by_id

void Connectiontest::test_CreateOperation_account_by_id()
{
    Create op;
    OpVector res;
    Anonymous op_arg;
    op->setArgs1(op_arg);
    op_arg->setId("jim");
    // Legacy op
    m_connection->operation(op, res);
    ASSERT_EQUAL(m_connection->m_objects.size(), 0u);
    ASSERT_TRUE(Router_error_called);
}
开发者ID:9cat,项目名称:cyphesis,代码行数:12,代码来源:Connectiontest.cpp

示例7: test_CreateOperation_number_username

void Connectiontest::test_CreateOperation_number_username()
{
    Create op;
    OpVector res;
    Anonymous op_arg;
    op->setArgs1(op_arg);
    op_arg->setAttr("username", 1);
    // Malformed username
    m_connection->operation(op, res);
    ASSERT_EQUAL(m_connection->m_objects.size(), 0u);
    ASSERT_TRUE(Router_error_called);
}
开发者ID:9cat,项目名称:cyphesis,代码行数:12,代码来源:Connectiontest.cpp

示例8: test_CreateOperation_no_passed

void Connectiontest::test_CreateOperation_no_passed()
{
    Create op;
    OpVector res;
    Anonymous op_arg;
    op->setArgs1(op_arg);
    op_arg->setAttr("username", "jim");
    // username, no password
    m_connection->operation(op, res);
    ASSERT_EQUAL(m_connection->m_objects.size(), 0u);
    ASSERT_TRUE(Router_error_called);
}
开发者ID:9cat,项目名称:cyphesis,代码行数:12,代码来源:Connectiontest.cpp

示例9: test_CreateOperation

void Connectiontest::test_CreateOperation()
{
    Create op;
    OpVector res;
    Anonymous op_arg;
    op->setArgs1(op_arg);
    op_arg->setAttr("username", "jim");
    op_arg->setAttr("password", "foo");
    // valid username and password
    m_connection->operation(op, res);
    ASSERT_EQUAL(m_connection->m_objects.size(), 1u);
}
开发者ID:9cat,项目名称:cyphesis,代码行数:12,代码来源:Connectiontest.cpp

示例10: test_CreateOperation

void Accountintegration::test_CreateOperation()
{
    Anonymous op_arg;
    op_arg->setParents(std::list<std::string>(1, "game_entity"));
    op_arg->setName("Bob");

    Create op;
    op->setArgs1(op_arg);

    OpVector res;
    m_ac->operation(op, res);
}
开发者ID:9cat,项目名称:cyphesis,代码行数:12,代码来源:Accountintegration.cpp

示例11: test_CreateOperation_username

void Connectiontest::test_CreateOperation_username()
{
    Create op;
    OpVector res;
    Anonymous op_arg;
    op->setArgs1(op_arg);
    op_arg->setAttr("username", "");
    op_arg->setAttr("password", "foo");
    // zero length username
    m_connection->operation(op, res);
    ASSERT_EQUAL(m_connection->m_objects.size(), 0u);
    ASSERT_TRUE(Router_clientError_called);
}
开发者ID:9cat,项目名称:cyphesis,代码行数:13,代码来源:Connectiontest.cpp

示例12: run_operation_checks

void run_operation_checks(TestServerAccount * ac, Entity * chr, WorldRouter & world)
{
    // Entity injection test
    {
        Anonymous ent;

        // Add the test attributes
        ent->setAttr("objtype", "obj");
        ent->setAttr("name", "test_entity");
        ent->setParents(std::list<std::string>(1,"thing"));
        
        Create op;
        OpVector res;
        op->setArgs1(ent);
        ac->operation(op, res);
        
        Entity *reply = world.findByName("test_entity");
        assert(reply != 0);
    }
    
    // Regular create op tests
    {
        // This is the only op we've overridden
        Create op;
        OpVector res;
        ac->operation(op, res);
        op->setArgs1(Root());
        ac->operation(op, res);
        Anonymous op_arg;
        op->setArgs1(op_arg);
        ac->operation(op, res);
        op_arg->setParents(std::list<std::string>());
        ac->operation(op, res);
        op_arg->setParents(std::list<std::string>(1, "game_entity"));
        ac->operation(op, res);
        op_arg->setObjtype("obj");
        ac->operation(op, res);
        op_arg->setName("Bob");
        ac->operation(op, res);
        op_arg->setObjtype("class");
        ac->operation(op, res);
        op_arg->setId("game_entity");
        ac->operation(op, res);
        op_arg->setId("new_class");
        ac->operation(op, res);
        op_arg->setParents(std::list<std::string>(1, ""));
        ac->operation(op, res);
        op_arg->setParents(std::list<std::string>(1, "non_exist"));
        ac->operation(op, res);
    }
}
开发者ID:erikogenvik,项目名称:cyphesis,代码行数:51,代码来源:ServerAccounttest.cpp

示例13: handleMakeResponse

LocatedEntity * CreatorClient::make(const RootEntity & entity)
{
    Create op;
    op->setArgs1(entity);
    op->setFrom(getId());
    op->setTo(getId());
    OpVector result;
    if (sendAndWaitReply(op, result) != 0) {
        std::cerr << "No reply to make" << std::endl << std::flush;
        return NULL;
    }
    assert(!result.empty());
    const Operation & res = result.front();
    if (!res.isValid()) {
        std::cerr << "NULL reply to make" << std::endl << std::flush;
        return NULL;
    }
    // FIXME Make this more robust against an info response
    if (res->getClassNo() == Atlas::Objects::Operation::SIGHT_NO) {
        if (res->getArgs().empty()) {
            std::cerr << "Reply to make has no args" << std::endl << std::flush;
            return NULL;
        }
        RootOperation arg = smart_dynamic_cast<RootOperation>(res->getArgs().front());
        if (!arg.isValid()) {
            std::cerr << "Arg of reply to make is not an operation"
                      << std::endl << std::flush;
            return NULL;
        }
        if (arg->getClassNo() != Atlas::Objects::Operation::CREATE_NO) {
            std::cerr << "Reply to make isn't sight of create"
                      << std::endl << std::flush;
            return NULL;
        }
        return handleMakeResponse(arg, res->getSeconds());
    } else if (res->getClassNo() == Atlas::Objects::Operation::INFO_NO) {
        return handleMakeResponse(res, res->getSeconds());
    } else {
        std::cerr << "Reply to make isn't sight or info"
                  << std::endl << std::flush;
        return NULL;
    }
}
开发者ID:9cat,项目名称:cyphesis,代码行数:43,代码来源:CreatorClient.cpp

示例14: create

int AtlasStreamClient::create(const std::string & type,
                              const std::string & username,
                              const std::string & password)
{
    m_username = username;

    Create c;
    Anonymous account;

    account->setAttr("username", username);
    account->setAttr("password", password);
    account->setParents(std::list<std::string>(1, type));

    c->setArgs1(account);
    c->setSerialno(newSerialNo());

    send(c);

    return waitForLoginResponse();
}
开发者ID:9cat,项目名称:cyphesis,代码行数:20,代码来源:AtlasStreamClient.cpp

示例15: assert

void EntityImporterBase::createEntity(const RootEntity & obj, OpVector & res)
{
    ++mStats.entitiesProcessedCount;
    ++mStats.entitiesCreateCount;
    EventProgress.emit();

    m_state = ENTITY_CREATING;

    assert(mTreeStack.size() > 1);
    std::deque<StackEntry>::reverse_iterator I = mTreeStack.rbegin();
    ++I;
    assert(I != mTreeStack.rend());
    const std::string & loc = I->restored_id;

    RootEntity create_arg = obj.copy();

    create_arg->removeAttrFlag(Atlas::Objects::Entity::CONTAINS_FLAG);
    create_arg->removeAttrFlag(Atlas::Objects::Entity::VELOCITY_FLAG);
    create_arg->removeAttrFlag(Atlas::Objects::ID_FLAG);
    create_arg->setLoc(loc);

    //Remove any attribute which references another entity from the Create op.
    //This is because the attribute will at this time with certainty refer to the wrong or a non-existing entity.
    //The attribute will later on be set through a Set op in sendResolvedEntityReferences().
    auto referenceMapEntryI = mEntitiesWithReferenceAttributes.find(obj->getId());
    if (referenceMapEntryI != mEntitiesWithReferenceAttributes.end()) {
        for (const auto& attributeName : referenceMapEntryI->second) {
            create_arg->removeAttr(attributeName);
        }
    }

    Create create;
    create->setArgs1(create_arg);
    create->setFrom(mAvatarId);
    create->setSerialno(newSerialNumber());

    mCreateEntityMapping.insert(std::make_pair(create->getSerialno(), obj->getId()));

    res.push_back(create);
}
开发者ID:Arsakes,项目名称:cyphesis,代码行数:40,代码来源:EntityImporterBase.cpp


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