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


C++ Member类代码示例

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


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

示例1: myConfig

    /**
     * Choose a member to sync from. 
     *
     * The initalSync option is an object with 1 k/v pair:
     * 
     * "state" : 1|2
     * "name" : "host"
     * "_id" : N
     * "optime" : t
     *
     * All except optime are exact matches.  "optime" will find a secondary with
     * an optime >= to the optime given.
     */
    const Member* ReplSetImpl::getMemberToSyncTo() {
        BSONObj sync = myConfig().initialSync;
        bool secondaryOnly = false, isOpTime = false;
        char *name = 0;
        int id = -1;
        OpTime optime;

        StateBox::SP sp = box.get();
        assert( !sp.state.primary() ); // wouldn't make sense if we were.

        // if it exists, we've already checked that these fields are valid in
        // rs_config.cpp
        if ( !sync.isEmpty() ) {
            if (sync.hasElement("state")) {
                if (sync["state"].Number() == 1) {
                    if (sp.primary) {
                        sethbmsg( str::stream() << "syncing to primary: " << sp.primary->fullName(), 0);
                        return const_cast<Member*>(sp.primary);
                    }
                    else {
                        sethbmsg("couldn't clone from primary");
                        return NULL;
                    }
                }
                else {
                    secondaryOnly = true;
                }
            }
            if (sync.hasElement("name")) {
                name = (char*)sync["name"].valuestr();
            }
            if (sync.hasElement("_id")) {
                id = (int)sync["_id"].Number();
            }
            if (sync.hasElement("optime")) {
                isOpTime = true;
                optime = sync["optime"]._opTime();
            }
        }
        
        for( Member *m = head(); m; m = m->next() ) {
            if (!m->hbinfo().up() ||
                (m->state() != MemberState::RS_SECONDARY &&
                 m->state() != MemberState::RS_PRIMARY) ||
                (secondaryOnly && m->state() != MemberState::RS_SECONDARY) ||
                (id != -1 && (int)m->id() != id) ||
                (name != 0 && strcmp(name, m->fullName().c_str()) != 0) ||
                (isOpTime && optime >= m->hbinfo().opTime)) {
                continue;
            }

            sethbmsg( str::stream() << "syncing to: " << m->fullName(), 0);
            return const_cast<Member*>(m);
        }
        
        sethbmsg( str::stream() << "couldn't find a member matching the sync criteria: " <<
                  "\nstate? " << (secondaryOnly ? "2" : "none") <<
                  "\nname? " << (name ? name : "none") <<
                  "\n_id? " << id <<
                  "\noptime? " << optime.toStringPretty() );
        
        return NULL;
    }
开发者ID:ALFIO,项目名称:mongo,代码行数:76,代码来源:rs_initialsync.cpp

示例2: membershipID

	HealthData::HealthData(Member& trainee) :
	membershipID(trainee.getMembershipID()),
	height(trainee.getHeight()),
	weight(trainee.getWeight())
	{
	}
开发者ID:TomFrampton,项目名称:Cpp-MultiClientServer,代码行数:6,代码来源:HealthData.cpp

示例3: delegate_handler

static int
delegate_handler( Member* member, CAtom* atom, PyObject* value )
{
    Member* delegate = member_cast( member->setattr_context );
    return delegate->setattr( atom, value );
}
开发者ID:nucleic,项目名称:atom,代码行数:6,代码来源:setattrbehavior.cpp

示例4: lk

    Member* ReplSetImpl::getMemberToSyncTo() {
        lock lk(this);

        bool buildIndexes = true;

        // if we have a target we've requested to sync from, use it

        if (_forceSyncTarget) {
            Member* target = _forceSyncTarget;
            _forceSyncTarget = 0;
            sethbmsg( str::stream() << "syncing to: " << target->fullName() << " by request", 0);
            return target;
        }

        // wait for 2N pings before choosing a sync target
        if (_cfg) {
            int needMorePings = config().members.size()*2 - HeartbeatInfo::numPings;

            if (needMorePings > 0) {
                OCCASIONALLY log() << "waiting for " << needMorePings << " pings from other members before syncing" << endl;
                return NULL;
            }

            buildIndexes = myConfig().buildIndexes;
        }

        // find the member with the lowest ping time that has more data than me

        // Find primary's oplog time. Reject sync candidates that are more than
        // MAX_SLACK_TIME seconds behind.
        OpTime primaryOpTime;
        static const unsigned maxSlackDurationSeconds = 10 * 60; // 10 minutes
        const Member* primary = box.getPrimary();
        if (primary) 
            primaryOpTime = primary->hbinfo().opTime;
        else
            // choose a time that will exclude no candidates, since we don't see a primary
            primaryOpTime = OpTime(maxSlackDurationSeconds, 0);

        if ( primaryOpTime.getSecs() < maxSlackDurationSeconds ) {
            // erh - I think this means there was just a new election
            // and we don't yet know the new primary's optime
            primaryOpTime = OpTime(maxSlackDurationSeconds, 0);
        }

        OpTime oldestSyncOpTime(primaryOpTime.getSecs() - maxSlackDurationSeconds, 0);

        Member *closest = 0;
        time_t now = 0;

        // Make two attempts.  The first attempt, we ignore those nodes with
        // slave delay higher than our own.  The second attempt includes such
        // nodes, in case those are the only ones we can reach.
        // This loop attempts to set 'closest'.
        for (int attempts = 0; attempts < 2; ++attempts) {
            for (Member *m = _members.head(); m; m = m->next()) {
                if (!m->hbinfo().up())
                    continue;
                // make sure members with buildIndexes sync from other members w/indexes
                if (buildIndexes && !m->config().buildIndexes)
                    continue;

                if (!m->state().readable())
                    continue;

                if (m->state() == MemberState::RS_SECONDARY) {
                    // only consider secondaries that are ahead of where we are
                    if (m->hbinfo().opTime <= lastOpTimeWritten)
                        continue;
                    // omit secondaries that are excessively behind, on the first attempt at least.
                    if (attempts == 0 && 
                        m->hbinfo().opTime < oldestSyncOpTime)
                        continue;
                }

                // omit nodes that are more latent than anything we've already considered
                if (closest && 
                    (m->hbinfo().ping > closest->hbinfo().ping))
                    continue;

                if ( attempts == 0 &&
                     myConfig().slaveDelay < m->config().slaveDelay ) {
                    continue; // skip this one in the first attempt
                }

                map<string,time_t>::iterator vetoed = _veto.find(m->fullName());
                if (vetoed != _veto.end()) {
                    // Do some veto housekeeping
                    if (now == 0) {
                        now = time(0);
                    }

                    // if this was on the veto list, check if it was vetoed in the last "while".
                    // if it was, skip.
                    if (vetoed->second >= now) {
                        if (time(0) % 5 == 0) {
                            log() << "replSet not trying to sync from " << (*vetoed).first
                                  << ", it is vetoed for " << ((*vetoed).second - now) << " more seconds" << rsLog;
                        }
                        continue;
//.........这里部分代码省略.........
开发者ID:cwestin,项目名称:mongo,代码行数:101,代码来源:rs_initialsync.cpp

示例5: assert

    void ReplSetImpl::_summarizeStatus(BSONObjBuilder& b) const {
        vector<BSONObj> v;

        const Member *_self = this->_self;
        assert( _self );

        // add self
        {
            BSONObjBuilder bb;
            bb.append("_id", (int) _self->id());
            bb.append("name", _self->fullName());
            bb.append("health", 1.0);
            bb.append("state", (int) box.getState().s);
            bb.append("stateStr", box.getState().toString());
            bb.appendTimestamp("optime", lastOpTimeWritten.asDate());
            bb.appendDate("optimeDate", lastOpTimeWritten.getSecs() * 1000LL);
            string s = _self->lhb();
            if( !s.empty() )
                bb.append("errmsg", s);
            bb.append("self", true);
            v.push_back(bb.obj());
        }

        Member *m =_members.head();
        while( m ) {
            BSONObjBuilder bb;
            bb.append("_id", (int) m->id());
            bb.append("name", m->fullName());
            double h = m->hbinfo().health;
            bb.append("health", h);
            bb.append("state", (int) m->state().s);
            if( h == 0 ) {
                // if we can't connect the state info is from the past and could be confusing to show
                bb.append("stateStr", "(not reachable/healthy)");
            }
            else {
                bb.append("stateStr", m->state().toString());
            }
            bb.append("uptime", (unsigned) (m->hbinfo().upSince ? (time(0)-m->hbinfo().upSince) : 0));
            bb.appendTimestamp("optime", m->hbinfo().opTime.asDate());
            bb.appendDate("optimeDate", m->hbinfo().opTime.getSecs() * 1000LL);
            bb.appendTimeT("lastHeartbeat", m->hbinfo().lastHeartbeat);
            bb.append("ping", m->hbinfo().ping);
            string s = m->lhb();
            if( !s.empty() )
                bb.append("errmsg", s);
            v.push_back(bb.obj());
            m = m->next();
        }
        sort(v.begin(), v.end());
        b.append("set", name());
        b.appendTimeT("date", time(0));
        b.append("myState", box.getState().s);
        if (_currentSyncTarget) {
            b.append("syncingTo", _currentSyncTarget->fullName());
        }
        b.append("members", v);
        if( replSetBlind )
            b.append("blind",true); // to avoid confusion if set...normally never set except for testing.
    }
开发者ID:kzys,项目名称:mongo,代码行数:60,代码来源:health.cpp

示例6: viewLodging

	int viewLodging(Member & member) //예약확인
	{

		system("clear");
		


		RoomList rl;
		int memnum;
		memnum = member.getMNumber();
		fileIO::loadBookUser(rl, memnum);
		Room a = rl.getFirstRoom();
		int size = rl.getSize();
			


		int y,m,d,p, r, l, person;
		int x = 1;	

		cout << "******************************************************************************" <<endl;
		cout << "              			나의 예약 현황" <<endl;
		cout << "******************************************************************************" <<endl;



	
		if( size > 0 )
		{

	 		y = a.getMYear();
			m = a.getMMonth();
			d = a.getMDay();
			p = a.getMPeriod();
			r = a.getRNumber();
			person = a.getMPerson();
			l = a.getLNumber();
			cout << "			Hotel Number : " << l <<endl;
			cout << "			RNUMBER : " << r << endl;
			cout << "			HEAD COUNT : " << person << endl;
			cout << "			DATE : "<< y << " " << m << " " << d << "부터 " << p << "일 동안" << endl;
			cout << "----------------------------------------------------------------------------" <<endl;

		}

		while ( x < size )
		{
	 		Room b = rl.getNextRoom();
			y = b.getMYear();
			m = b.getMMonth();
			d = b.getMDay();
			p = b.getMPeriod();
			r = b.getRNumber();
			l = a.getLNumber();
			cout << "			Hotel Number : " << l <<endl;			
			cout << "			RNUMBER : " << r << endl;
			cout << "			HEAD COUNT : " << person << endl;
			cout << "			DATE : "<< y << " " << m << " " << d << "부터 " << p << "일 동안" << endl;
			cout << "----------------------------------------------------------------------------" <<endl;

			x++;

		}
	


	cin.ignore(1024, '\n');
	
	}
开发者ID:NalRo9,项目名称:lodging,代码行数:68,代码来源:reservation.cpp

示例7: aMajoritySeemsToBeUp

 bool Consensus::aMajoritySeemsToBeUp() const {
     int vUp = rs._self->config().votes;
     for( Member *m = rs.head(); m; m=m->next() )
         vUp += m->hbinfo().up() ? m->config().votes : 0;
     return vUp * 2 > _totalVotes();
 }
开发者ID:BeyondMyself,项目名称:mongo,代码行数:6,代码来源:consensus.cpp

示例8: config

 void ReplSetImpl::_getTargets(list<Target>& L, int& configVersion) {
     configVersion = config().version;
     for( Member *m = head(); m; m=m->next() )
         if( m->hbinfo().maybeUp() )
             L.push_back( Target(m->fullName()) );
 }
开发者ID:BeyondMyself,项目名称:mongo,代码行数:6,代码来源:consensus.cpp

示例9: delegate_handler

static int
delegate_handler( Member* member, CAtom* atom )
{
    Member* delegate = member_cast( member->delattr_context );
    return delegate->delattr( atom );
}
开发者ID:BBN-Q,项目名称:atom,代码行数:6,代码来源:delattrbehavior.cpp

示例10: lk

    /** @param reconf true if this is a reconfiguration and not an initial load of the configuration.
        @return true if ok; throws if config really bad; false if config doesn't include self
    */
    bool ReplSetImpl::initFromConfig(ReplSetConfig& c, bool reconf) {
        /* NOTE: haveNewConfig() writes the new config to disk before we get here.  So 
                 we cannot error out at this point, except fatally.  Check errors earlier.
                 */
        lock lk(this);

        if( getLastErrorDefault || !c.getLastErrorDefaults.isEmpty() ) {
            // see comment in dbcommands.cpp for getlasterrordefault
            getLastErrorDefault = new BSONObj( c.getLastErrorDefaults );
        }

        list<const ReplSetConfig::MemberCfg*> newOnes;
        bool additive = reconf;
        {
            unsigned nfound = 0;
            int me = 0;
            for( vector<ReplSetConfig::MemberCfg>::iterator i = c.members.begin(); i != c.members.end(); i++ ) { 
                const ReplSetConfig::MemberCfg& m = *i;
                if( m.h.isSelf() ) {
                    nfound++;
                    me++;
                    if( !reconf || (_self && _self->id() == (unsigned) m._id) )
                        ;
                    else { 
                        log() << "replSet " << _self->id() << ' ' << m._id << rsLog;
                        assert(false);
                    }
                }
                else if( reconf ) { 
                    const Member *old = findById(m._id);
                    if( old ) { 
                        nfound++;
                        assert( (int) old->id() == m._id );
                        if( old->config() == m ) { 
                            additive = false;
                        }
                    }
                    else {
                        newOnes.push_back(&m);
                    }
                }
            }
            if( me == 0 ) {
                // log() << "replSet config : " << _cfg->toString() << rsLog;
                log() << "replSet error self not present in the repl set configuration:" << rsLog;
                log() << c.toString() << rsLog;
                uasserted(13497, "replSet error self not present in the configuration");
            }
            uassert( 13302, "replSet error self appears twice in the repl set configuration", me<=1 );

            if( reconf && config().members.size() != nfound ) 
                additive = false;
        }

        _cfg = new ReplSetConfig(c);
        assert( _cfg->ok() );
        assert( _name.empty() || _name == _cfg->_id );
        _name = _cfg->_id;
        assert( !_name.empty() );

        if( additive ) { 
            log() << "replSet info : additive change to configuration" << rsLog;
            for( list<const ReplSetConfig::MemberCfg*>::const_iterator i = newOnes.begin(); i != newOnes.end(); i++ ) {
                const ReplSetConfig::MemberCfg* m = *i;
                Member *mi = new Member(m->h, m->_id, m, false);

                /** we will indicate that new members are up() initially so that we don't relinquish our 
                    primary state because we can't (transiently) see a majority.  they should be up as we 
                    check that new members are up before getting here on reconfig anyway.
                    */
                mi->get_hbinfo().health = 0.1;

                _members.push(mi);
                startHealthTaskFor(mi);
            }
            return true;
        }

        // start with no members.  if this is a reconfig, drop the old ones.
        _members.orphanAll();

        endOldHealthTasks();

        int oldPrimaryId = -1;
        {
            const Member *p = box.getPrimary();
            if( p ) 
                oldPrimaryId = p->id();
        }
        forgetPrimary();
        setSelfTo(0);
        for( vector<ReplSetConfig::MemberCfg>::iterator i = _cfg->members.begin(); i != _cfg->members.end(); i++ ) { 
            const ReplSetConfig::MemberCfg& m = *i;
            Member *mi;
            if( m.h.isSelf() ) {
                assert( _self == 0 );
                mi = new Member(m.h, m._id, &m, true);
//.........这里部分代码省略.........
开发者ID:sivy,项目名称:mongo,代码行数:101,代码来源:rs.cpp

示例11: lk

/** @param reconf true if this is a reconfiguration and not an initial load of the configuration.
    @return true if ok; throws if config really bad; false if config doesn't include self
*/
bool ReplSetImpl::initFromConfig(ReplSetConfig& c, bool reconf) {
    /* NOTE: haveNewConfig() writes the new config to disk before we get here.  So
             we cannot error out at this point, except fatally.  Check errors earlier.
             */
    lock lk(this);

    if( getLastErrorDefault || !c.getLastErrorDefaults.isEmpty() ) {
        // see comment in dbcommands.cpp for getlasterrordefault
        getLastErrorDefault = new BSONObj( c.getLastErrorDefaults );
    }

    list<const ReplSetConfig::MemberCfg*> newOnes;
    // additive short-cuts the new config setup. If we are just adding a
    // node/nodes and nothing else is changing, this is additive. If it's
    // not a reconfig, we're not adding anything
    bool additive = reconf;
    {
        unsigned nfound = 0;
        int me = 0;
        for( vector<ReplSetConfig::MemberCfg>::iterator i = c.members.begin(); i != c.members.end(); i++ ) {
            const ReplSetConfig::MemberCfg& m = *i;

            if( m.h.isSelf() ) {
                me++;
            }

            if( reconf ) {
                if (m.h.isSelf() && (!_self || (int)_self->id() != m._id)) {
                    log() << "self doesn't match: " << m._id << rsLog;
                    assert(false);
                }

                const Member *old = findById(m._id);
                if( old ) {
                    nfound++;
                    assert( (int) old->id() == m._id );
                    if( old->config() != m ) {
                        additive = false;
                    }
                }
                else {
                    newOnes.push_back(&m);
                }
            }
        }
        if( me == 0 ) {
            _members.orphanAll();
            // hbs must continue to pick up new config
            // stop sync thread
            box.set(MemberState::RS_STARTUP, 0);

            // go into holding pattern
            log() << "replSet error self not present in the repl set configuration:" << rsLog;
            log() << c.toString() << rsLog;
            return false;
        }
        uassert( 13302, "replSet error self appears twice in the repl set configuration", me<=1 );

        // if we found different members that the original config, reload everything
        if( reconf && config().members.size() != nfound )
            additive = false;
    }

    _cfg = new ReplSetConfig(c);
    assert( _cfg->ok() );
    assert( _name.empty() || _name == _cfg->_id );
    _name = _cfg->_id;
    assert( !_name.empty() );

    // this is a shortcut for simple changes
    if( additive ) {
        log() << "replSet info : additive change to configuration" << rsLog;
        for( list<const ReplSetConfig::MemberCfg*>::const_iterator i = newOnes.begin(); i != newOnes.end(); i++ ) {
            const ReplSetConfig::MemberCfg* m = *i;
            Member *mi = new Member(m->h, m->_id, m, false);

            /** we will indicate that new members are up() initially so that we don't relinquish our
                primary state because we can't (transiently) see a majority.  they should be up as we
                check that new members are up before getting here on reconfig anyway.
                */
            mi->get_hbinfo().health = 0.1;

            _members.push(mi);
            startHealthTaskFor(mi);
        }
        return true;
    }

    // start with no members.  if this is a reconfig, drop the old ones.
    _members.orphanAll();

    endOldHealthTasks();

    int oldPrimaryId = -1;
    {
        const Member *p = box.getPrimary();
        if( p )
//.........这里部分代码省略.........
开发者ID:web-os,项目名称:mongo,代码行数:101,代码来源:rs.cpp

示例12: loadSqlMembers

void SecurityManager::loadMembers()
{
    if (isSql()) {
        loadSqlMembers();
        return;
    }
    const char *path = "serverdb/members.txt";
    const char *backup = "serverdb/members.backup.txt";
    {
        QDir d;
        d.mkdir("serverdb");
    }

    if (!QFile::exists(path) && QFile::exists(backup)) {
        QFile::rename(backup, path);
    }

    memberFile.setFileName(path);
    if (!memberFile.open(QFile::ReadWrite)) {
        throw QObject::tr("Error: cannot open the file that contains the members (%1)").arg(path);
    }

    int pos = memberFile.pos();
    while (!memberFile.atEnd()) {
        QByteArray arr = memberFile.readLine();
        QString s = QString::fromUtf8(arr.constData(), std::max(0,arr.length()-1)); //-1 to remove the \n

        QStringList ls = s.split('%');

        if (ls.size() >= 6 && isValid(ls[0])) {
            Member m (ls[0], ls[1].trimmed(), ls[2][0].toLatin1() - '0', ls[2][1] == '1', ls[3].trimmed().toLatin1(), ls[4].trimmed().toLatin1(), ls[5].trimmed());

            if (ls.size() >= 7) {
                m.ban_expire_time = ls[6].toInt();
            }

            m.filepos = pos;
            members[ls[0]] = m;

            /* Update pos for next iteration */
            pos = memberFile.pos();

            if (m.isBanned()) {
                bannedIPs.insert(m.ip, m.ban_expire_time);
                bannedMembers.insert(m.name.toLower(), std::pair<QString, int>(m.ip, m.ban_expire_time));
            }
            if (m.authority() > 0) {
                authed.insert(m.name);
            }
            playersByIp.insert(m.ip, m.name);
        }
        lastPlace = memberFile.pos();
    }

    //We also clean up the file by rewritting it with only the valid contents
    QFile temp (backup);
    if (!temp.open(QFile::WriteOnly | QFile::Truncate))
        throw QObject::tr("Impossible to change %1").arg(backup);

    pos = temp.pos();

    for(auto it = members.begin(); it != members.end(); ++it) {
        Member &m = it->second;
        m.write(&temp);
        m.filepos = pos;
        pos = temp.pos();
    }

    lastPlace = temp.pos();

    temp.flush();
    memberFile.remove();

    if (!temp.rename(path)) {
        throw QObject::tr("Error: cannot rename the file that contains the members (%1 -> %2)").arg(backup).arg(path);
    }

    temp.rename(path);

    if (!memberFile.open(QFile::ReadWrite)) {
        throw QObject::tr("Error: cannot reopen the file that contains the members (%1)").arg(path);
    }
}
开发者ID:Jirachier,项目名称:pokemon-online,代码行数:83,代码来源:security.cpp

示例13: getId

/// Given a Reflex::Member object, return the id for the configurable (name or id, if it is a string).
/// non-string ids are used for the persistency (DataObjects)
inline std::string getId(const Member & m) {
      return (m.Properties().HasProperty("id") && (m.Properties().PropertyValue("id").TypeInfo() == typeid(std::string))) ?
             m.Properties().PropertyAsString("id") :
             m.Properties().PropertyAsString("name") ;
}
开发者ID:atlas-org,项目名称:gaudi,代码行数:7,代码来源:genconf.cpp

示例14: LOG

int Msm::epoll_pollin(int fd)
{
        LOG(LOG_DEBUG, "socket: %d EPOLLIN event.", fd);

        char buf[1024];
        memset(buf, 0, sizeof(buf));
        // int rc = recv(events[n].data.fd, buf, sizeof(buf)-1, 0);


        struct msghdr msghdr;
        struct iovec iov;

        memset(&msghdr, 0, sizeof(msghdr));
        iov.iov_base = buf;
        iov.iov_len = sizeof(buf);

        msghdr.msg_iov = &iov;
        msghdr.msg_iovlen = 1;

        int rc = recvmsg(fd, &msghdr, 0);

        if (rc == -1) {
                LOG(LOG_ERROR, "socket: %d recvmsg failed: %s", fd, strerror(errno));
                return -1;
        } else if (rc == 0) {
                LOG(LOG_ERROR, "socket: %d recvmsg 0, socket is closed by user.", fd);
                if (get_member_byfd(fd) != NULL) {
                        logout(get_member_byfd(fd)->get_id());
                }
                return -1;
        }
        LOG(LOG_DEBUG, "socket: %d recvmsg:\n%s", fd, buf);
        Json::Value root;
        Json::Reader reader;
        if (reader.parse(buf, root, false) == false) {
                LOG(LOG_DEBUG, "json parse failed.");
                return -1;
        }

        if (epoll_closefd_before(root["action"].asString(), fd, root["user_id"].asString()) < 0)
                return -1;

        msm_msg_t msm_msg;
        msm_msg.sockfd = fd;
        msm_msg.root = root;
        msm_msg.msm = this;

        actions_handle.find(root["action"].asString())->second(msm_msg);

#if 0
        if (root["action"] == "login") {

                login(root["user_id"].asString(), root["user_name"].asString(), fd);
                // send_test(root["from"].asString());
        } else if (root["action"] == "logout") {

                logout(root["user_id"].asString());

        } else if (root["action"] == "heartbeat") {


        } else if (root["action"] == "askmeeting") {


                create_meeting(root["meeting_id"].asString(), root["meeting_name"].asString());
                get_meeting(root["meeting_id"].asString())->add_member(get_member(root["user_id"].asString()));
                get_meeting(root["meeting_id"].asString())->set_admin(root["user_id"].asString());

        } else if (root["action"] == "adduser") {
                if (get_meeting(root["meeting_id"].asString()) != NULL) {
                        if (get_member(root["users"].asString()) == NULL) {
                                Member *m = new Member(root["users"].asString(), "Unkown");
                                m->set_offline();
                                register_member(m);
                        }
                        get_meeting(root["meeting_id"].asString())->add_member(get_member(root["users"].asString()));
                }
        } else if (root["action"] == "leavemeeting") {
                Meeting *meeting = get_meeting(root["meeting_id"].asString());
                if (meeting != NULL) {
                        Member *m = get_member(root["user_id"].asString());
                        if (m->get_id() != meeting->get_admin()) {
                                meeting->del_member(m);
                        } else {
                                destroy_meeting(meeting->get_id());
                        }
                }
        } else {


        }
#endif
        epoll_closefd_after(root["action"].asString(), fd, root["user_id"].asString());
        dump_members();
        dump_meetings();
        return 0;
}
开发者ID:github188,项目名称:msm,代码行数:97,代码来源:msm.cpp

示例15: distinct

/*************************************************************
 * another kind of function that return a set
 ************************************************************/
std::vector<QueryTuple*> SetFunFactory::funInstance(XSchema* _pSch, 
										            std::string& _cubeName, 
									                SetTypesec _typesec, 
									                std::vector<std::string>& theVector,
													FunParam *param)
{
    int size = theVector.size();
    XCube* pCube = _pSch->getCube(_cubeName);
	vector<QueryMember*> QmemVector;
	vector<QueryTuple*> QtupleVector;

	string dimName = "";
	string hieName = "";			
	Dimension* pDim = NULL;
	Hierarchy* pHie = NULL;
				
	if (isDimHie(theVector.at(0)))
	{
		vector<string> temp = distinct(theVector.at(0));
		dimName = temp.at(0);
		pDim = pCube->getDimension(temp.at(0));
		assert(pDim);
		hieName = temp.at(1);
		pHie = pDim->getHierarchy(temp.at(1));
		assert(pHie);
	}
			  
	else
	{
		dimName = theVector.at(0);
		pDim = pCube->getDimension(theVector.at(0));
		assert(pDim);
		pHie = pDim->getDefaultHierarchy();
	}
	assert(pHie);
	hieName = pHie->getName();
	
	//首先把Member从数据库中load出来
	pHie->LoadMembers();
	
	switch(_typesec)
	{
		//函数Members的处理对象
		//对于[Time].[Time].[1995].[Q1].[Month].Members
		//theVector中应依次存有string:Time, Time, 1995, Q1, Month
	case Members:
		if (size == 0 )
		{
			cout<<"error! please input query information..."<<endl;
		}
		else if (size == 1) //由于现在还不支持多个Hierarchy,所以size 为1、2结果是一样的
		{   
			if ((theVector.at(0) == "Measures")||(theVector.at(0) == "measures"))
			{
				//元数据现在还没有支持默认度量,先以第一个度量为默认的
				vector<Measure*> vecMea = pCube->getMeasures();
				vector<Measure*>::iterator meaIterator;
				if (!vecMea.empty())
				{
					for (meaIterator = vecMea.begin(); meaIterator < vecMea.end(); meaIterator++)
					{
						std::auto_ptr<QueryMember>pMem(new QueryMember);
	                    
						pMem->setHierarchyName("Measures");
						pMem->setLevelName("Measures");
					    pMem->setVal((*meaIterator)->getName());

						QmemVector.push_back(pMem.release());
						std::auto_ptr<QueryTuple>pTuple(new QueryTuple(QmemVector));
						QmemVector.pop_back();
						QtupleVector.push_back(pTuple.release());
					}
				}
 				
 				return QtupleVector;
			} 
			else
			{
				string hierarcyName = pHie->getName();
				vector<string> vecLevelName;
	//			vector< vector<string> > memNameInLevels;//用于存储每个Level上成员名字的vector
				
				vector<Level*> vecLevel = pHie->getLeveles();

				Member* temp = (vecLevel.at(0)->getMembers()).at(0);//获取第一个级别第一个成员
				
				getDescendants(temp,dimName,hieName,QtupleVector); // 获取该成员的所有后代
				
				pHie->CleanMembers();
				return QtupleVector;
				
			}
		}

		else if (size == 2)
		{   
			
//.........这里部分代码省略.........
开发者ID:mydw,项目名称:mydw,代码行数:101,代码来源:SetFunFactory.cpp


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