Esempio n. 1
0
int main()
{
    Monitors m;

    int foo = 7;
    std::stringstream ss;

    m.watch("foo", new Variable<int>(foo));

    m.insert("bar", 3);
    m.insert("mim", 3.f);
    m.insert("qux", "three");

    // positive check
    assert( m.readVariable("foo",ss) == 0 );
    assert( ss.str().compare("7") == 0 );

    // negative check
    ss.clear();
    assert(m.readVariable("nonexistent",ss) != 0);

    m.send(std::cout);

    return 0;
}
Esempio n. 2
0
/// \brief Constructor for server object.
///
/// Requires a reference to the World management object, as well as the
/// ruleset and server name. Implicitly creates the Lobby management object.
ServerRouting::ServerRouting(BaseWorld & wrld,
                             const std::string & ruleset,
                             const std::string & name,
                             const std::string & id, long intId,
                             const std::string & lId, long lIntId) :
        Router(id, intId),
        m_svrRuleset(ruleset), m_svrName(name),
        m_numClients(0), m_world(wrld), m_lobby(*new Lobby(*this, lId, lIntId))
{
    Monitors * monitors = Monitors::instance();
    monitors->insert("server", "cyphesis");
    monitors->insert("builddate", String::compose("%1, %2",
                                                  consts::buildDate,
                                                  consts::buildTime));
    monitors->watch("instance", new Variable<std::string>(::instance));
    monitors->watch("name", new Variable<std::string>(m_svrName));
    monitors->watch("ruleset", new Variable<std::string>(m_svrRuleset));
    monitors->watch("version", new Variable<const char *>(consts::version));
    monitors->watch("buildid", new Variable<int>(consts::buildId));
    monitors->watch("clients", new Variable<int>(m_numClients));

    m_instance = this;
}
Esempio n. 3
0
int main()
{
    Monitors * m = Monitors::instance();

    assert(m != 0);

    int foo = 1;

    m->watch("foo", new Variable<int>(foo));

    m->insert("bar", 3);
    m->insert("mim", 3.f);
    m->insert("qux", "three");

    m->send(std::cout);

    Monitors::cleanup();
    return 0;
}