本文整理汇总了C++中Network::addListener方法的典型用法代码示例。如果您正苦于以下问题:C++ Network::addListener方法的具体用法?C++ Network::addListener怎么用?C++ Network::addListener使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Network
的用法示例。
在下文中一共展示了Network::addListener方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
Network n;
TestGame g(&n);
if (argc>1) n.addListener(argv[1]);
QTimer::singleShot(1000, &g, SLOT(startOnEmpty()));
return app.exec();
}
示例2: if
/**
* @brief (Re-)loads configuration from the configuration file.
*
* If loading failed, this method returns false.
* Note: this method is automatically called when setConfigFileName is called,
* and by the constructor.
*/
bool dazeus::DaZeus::loadConfig()
{
assert( configFileName_.length() != 0 );
if( config_ != 0 ) {
delete config_;
}
config_ = new ConfigReader(configFileName_);
if( !config_ )
return false;
config_->read();
const std::vector<NetworkConfig*> &networks = config_->getNetworks();
if(!connectDatabase()) {
delete config_;
config_ = 0;
return false;
}
if(plugins_)
delete plugins_;
plugins_ = new PluginComm( database_, config_, this );
std::vector<NetworkConfig*>::const_iterator it;
for(it = networks.begin(); it != networks.end(); ++it)
{
Network *net = new Network( *it );
net->addListener(plugins_);
if( net == 0 ) {
delete config_;
config_ = 0;
return false;
}
networks_.push_back( net );
}
// Pretty number of initialisations viewer -- and also an immediate database
// check.
std::stringstream numInitsStr;
numInitsStr << database_->property("dazeus.numinits");
int numInits;
numInitsStr >> numInits;
if(!numInitsStr)
numInits = 0;
++numInits;
numInitsStr.str(""); numInitsStr.clear();
numInitsStr << numInits;
database_->setProperty("dazeus.numinits", numInitsStr.str());
const char *suffix = "th";
if(numInits%100 == 11 ) ;
else if(numInits%100 == 12) ;
else if(numInits%100 == 13) ;
else if(numInits%10 == 1) suffix = "st";
else if(numInits%10 == 2) suffix = "nd";
else if(numInits%10 == 3) suffix = "rd";
printf("Initialising DaZeus for the %d%s time!\n", numInits, suffix);
return true;
}