本文整理汇总了C++中Configurator类的典型用法代码示例。如果您正苦于以下问题:C++ Configurator类的具体用法?C++ Configurator怎么用?C++ Configurator使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Configurator类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: create_init_string
static std::string create_init_string(const Configurator& config)
{
return std::string("amqp:tcp:")
+ config.host()
+ ":"
+ std::to_string(config.port());
}
示例2: TEST_WITH_WORKDIR
// Check that when we specify a conf directory on the command line,
// we load values from the config file first and then the command line
TEST_WITH_WORKDIR(ConfiguratorTest, CommandLineConfFlag)
{
if (mkdir("bin", 0755) != 0)
FAIL() << "Failed to create directory bin";
if (mkdir("conf2", 0755) != 0)
FAIL() << "Failed to create directory conf2";
ofstream file("conf2/mesos.conf");
file << "a=1\n";
file << "b=2\n";
file << "c=3";
file.close();
const int ARGC = 4;
char* argv[ARGC];
argv[0] = (char*) "bin/filename";
argv[1] = (char*) "--conf=conf2";
argv[2] = (char*) "--b=overridden";
argv[3] = (char*) "--d=fromCmdLine";
Configurator conf;
EXPECT_NO_THROW( conf.load(ARGC, argv) );
EXPECT_EQ("1", conf.getConfiguration()["a"]);
EXPECT_EQ("overridden", conf.getConfiguration()["b"]);
EXPECT_EQ("3", conf.getConfiguration()["c"]);
EXPECT_EQ("fromCmdLine", conf.getConfiguration()["d"]);
}
示例3: main
int main(int argc, char *argv[]) {
QGuiApplication* app = SailfishApp::application(argc, argv);
QQuickView* view = SailfishApp::createView();
Configurator config;
config.load();
//qmlRegisterType<Request>("Sailbook.Request", 1, 0, "Request");
qmlRegisterUncreatableType<Request>("App.Sailbook", 1, 0, "Request", QStringLiteral("Error"));
//qmlRegisterInterface<SessionManager>("SessionManager");
SessionManager session(QStringLiteral(APPID), config.getValue(QStringLiteral("token")).toString());
session.setExtendedPermission(SessionManager::ExtendedPermissions(
SessionManager::Email |
SessionManager::ManageNotifications |
SessionManager::ManagePages |
SessionManager::PublishActions |
SessionManager::ReadFriendList |
SessionManager::ReadInsights |
SessionManager::ReadMailbox |
SessionManager::ReadPageMailboxes |
SessionManager::ReadStream |
SessionManager::RsvpEvent
));
session.setUserDataPermission(SessionManager::UserDataPermissions(
SessionManager::UserAboutMe |
SessionManager::UserActionsBooks |
SessionManager::UserActionsMusic |
SessionManager::UserActionsNews |
SessionManager::UserActionsVideo |
SessionManager::UserActivities |
SessionManager::UserBirthday |
SessionManager::UserEducationHistory |
SessionManager::UserEvents |
SessionManager::UserFriends |
SessionManager::UserGamesActivity |
SessionManager::UserGroups |
SessionManager::UserHometown |
SessionManager::UserInterests |
SessionManager::UserLikes |
SessionManager::UserLocation |
SessionManager::UserPhotos |
SessionManager::UserRelationshipDetails |
SessionManager::UserRelationships |
SessionManager::UserReligionPolitics |
SessionManager::UserStatus |
SessionManager::UserTaggedPlaces |
SessionManager::UserVideos |
SessionManager::UserWebsite |
SessionManager::UserWorkHistory
));
view->rootContext()->setContextProperty("SessionManager", &session);
view->rootContext()->setContextProperty("Configurator", &config);
view->setSource(SailfishApp::pathTo("qml/sailbook.qml"));
view->show();
return app->exec();
}
示例4: main
int main(int argc, char *argv[])
{
Configurator configurator;
try {
configurator.parseParams(argc, argv);
} catch(const ParseError &e) {
std::cerr << e.getMessage() << '\n'
<< "См. " << configurator.programName() << " --help" << std::endl;
return 1;
}
if (configurator.needHelp()) {
std::cout << configurator.help() << std::endl;
return 0;
}
// чтобы программа запускалась в Qt Creator, сделай в папке, которую создаёт Creator такую штуку
// ln -s ../#{папка_с_текущим_проектом}/handbook.cnf .
srand(time(NULL));
try {
Runner runner(configurator);
runner.run();
} catch(const ParseError &e) {
std::cerr << e.getMessage() << std::endl;
return 1;
}
return 0;
}
示例5: getConcatenatedPath
bool Steering::loadConfig(std::string configFile)
{
std::string configFileFullPath = getConcatenatedPath(configFile, "SteeringModuleConfiguration");
printd(INFO, "Steering::loadConfig(): Loading configuration file %s\n",
configFileFullPath.c_str());
ConfigurationReader *cfgReader = new UfoXmlConfigurationReader( configFileFullPath );
Configurator *cfg = cfgReader->readConfig();
// we don't need the cfgReader any more:
delete cfgReader;
if ( cfg == 0 )
{
printd(ERROR, "Steering::loadConfig(): readConfig() failed!\n");
return false;
}
if ( ! cfg->bind() )
{
printd(ERROR, "Steering::loadConfig(): bind() failed!\n");
cfg->print();
return false;
}
// Configurator is no longer needed:
delete cfg;
printd(INFO,"Steering::loadConfig(): configuration has %d Flocks and %d independent Pilots.\n"
, UfoDB::the()->getFlocks().size(), UfoDB::the()->getPilots().size());
return true;
}
示例6: main
int main (int argc, char **argv)
{
Configurator conf;
conf.addOption<int>("port", 'p', "Port to listen on", 5050);
conf.addOption<string>("ip", "IP address to listen on");
local::registerOptions(&conf);
if (argc == 2 && string("--help") == argv[1]) {
usage(argv[0], conf);
exit(1);
}
Params params;
try {
params = conf.load(argc, argv, true);
} catch (ConfigurationException& e) {
cerr << "Configuration error: " << e.what() << endl;
exit(1);
}
Logging::init(argv[0], params);
if (params.contains("port"))
setenv("LIBPROCESS_PORT", params["port"].c_str(), 1);
if (params.contains("ip"))
setenv("LIBPROCESS_IP", params["ip"].c_str(), 1);
const PID &master = local::launch(params, false);
Process::wait(master);
return 0;
}
示例7: TEST
TEST(ConfiguratorTest, Environment)
{
setenv("MESOS_TEST", "working", true);
Configurator conf;
conf.load();
unsetenv("MESOS_TEST");
EXPECT_EQ("working", conf.getConfiguration()["test"]);
}
示例8: fullFileName
void Configurator::LogHandler(QtMsgType type, const QMessageLogContext &context, const QString &msg)
{
QByteArray localMsg = msg.toLocal8Bit();
QString stringMsg;
QString fullFileName(context.file);
QString file;
int lastPathSeparatorIndex = fullFileName.lastIndexOf(QDir::separator());
if (lastPathSeparatorIndex)
file = fullFileName.right(fullFileName.size() - lastPathSeparatorIndex - 1);
else
file = fullFileName;
QTextStream stream(&stringMsg);
switch (type) {
case QtDebugMsg:
stream << context.category << ".DEBUG: " << localMsg.constData() << " " << " in "
<< file << " " << context.line << endl;
break;
case QtWarningMsg:
stream << context.category << ".WARNING: " << localMsg.constData() << context.function
<< " " << file << context.line << endl << endl;
break;
case QtCriticalMsg:
stream << context.category << ".CRITICAL: " << localMsg.constData() << context.function
<< " " << file << context.line << endl << endl;
break;
case QtFatalMsg:
stream << context.category << ".FATAL: " << localMsg.constData() << context.function
<< file << context.line << endl << endl;
break;
default:
stream << context.category << ".INFO: " << localMsg.constData() <<endl;
}
QTextStream(stdout) << stringMsg;
Configurator *configurator = Configurator::getInstance();
QDir logDir = configurator->getBaseDir();
QString path = logDir.absoluteFilePath("log.txt");
QFile outFile(path);
QIODevice::OpenMode ioFlags = QIODevice::WriteOnly;
if (configurator->logFileIsCreated()) {
ioFlags |= QIODevice::Append;
} else {
ioFlags |= QIODevice::Truncate;
configurator->setFileCreatedFlag();
}
if (outFile.open(ioFlags)) {
QTextStream ts(&outFile);
ts << stringMsg;
}
if (type == QtFatalMsg)
abort();
}
示例9: configure
void PatternLoggingLayout::configure(Configurator& conf)
{
if (conf.getMode() == Configurator::FROM_CONF)
{
std::string sPattern;
conf.configure("pattern", sPattern, "");
if (!sPattern.empty())
{
setPattern(sPattern);
}
}
}
示例10: m_runAsService
TvnServer::TvnServer(bool runsInServiceContext, StringStorage vncIniDirPath /*""*/, bool runAsPortable /*=false*/ )
: Singleton<TvnServer>(),
ListenerContainer<TvnServerListener *>(),
m_runAsService(runsInServiceContext),
m_runPortable(runAsPortable),
m_rfbClientManager(0),
m_httpServer(0), m_controlServer(0), m_rfbServer(0)
{
Configurator *configurator = Configurator::getInstance();
configurator->setServiceFlag(m_runAsService);
configurator->setPortableRunFlag(m_runPortable);
configurator->setVncIniDirectoryPath ( vncIniDirPath.getString() );
configurator->load();
m_config = Configurator::getInstance()->getServerConfig();
resetLogFilePath();
m_log.changeLevel(m_config->getLogLevel());
Log::message(_T("TightVNC Server Build on %s"), BuildTime::DATE);
Log::info(_T("Initialize WinSock"));
try {
WindowsSocket::startup(2, 1);
} catch (Exception &ex) {
Log::interror(_T("%s"), ex.getMessage());
}
ZombieKiller *zombieKiller = new ZombieKiller();
m_rfbClientManager = new RfbClientManager(NULL);
m_rfbClientManager->addListener(this);
Configurator::getInstance()->addListener(this);
{
AutoLock l(&m_mutex);
restartMainRfbServer();
(void)m_extraRfbServers.reload(m_runAsService, m_rfbClientManager);
restartHttpServer();
restartControlServer();
}
}
示例11: main
int main(void)
{
Configurator configurator;
configurator.readCommandLine();
configurator.readConfig();
LOG(INFO) << "init done";
PacketGenerator testGenerator(SimpleTestTrafficGenerator, 100);
LOG(INFO) << testGenerator.generate(555);
std::cout << std::endl;
return 0;
}
示例12: demoMyType1View
void demoMyType1View(const Configurator& configurator)
{
//
// Explicit view selection and configuration
//
MyType1 value;
value.configure(configurator.getView("object.MyType1Last"));
cout << "Explicit call: " << value << endl;
value.configure(configurator.getView("object.MyType1"));
cout << "Explicit call (MERGE): " << value << endl;
}
示例13: MessageBox
int ControlApplication::runConfigurator(bool configService, bool isRunAsRequested)
{
// If not enough rights to configurate service, then restart application requesting
// admin access rights.
if (configService && (IsUserAnAdmin() == FALSE)) {
// If admin rights already requested and application still don't have them,
// then show error message and exit.
if (isRunAsRequested) {
MessageBox(0,
StringTable::getString(IDS_ADMIN_RIGHTS_NEEDED),
StringTable::getString(IDS_MBC_TVNCONTROL),
MB_OK | MB_ICONERROR);
return 0;
}
// Path to tvnserver binary.
StringStorage pathToBinary;
// Command line for child process.
StringStorage childCommandLine;
// Get path to tvnserver binary.
Environment::getCurrentModulePath(&pathToBinary);
// Set -dontelevate flag to tvncontrol know that admin rights already requested.
childCommandLine.format(_T("%s -dontelevate"), m_commandLine.getString());
// Start child.
try {
Shell::runAsAdmin(pathToBinary.getString(), childCommandLine.getString());
} catch (SystemException &sysEx) {
if (sysEx.getErrorCode() != ERROR_CANCELLED) {
MessageBox(0,
sysEx.getMessage(),
StringTable::getString(IDS_MBC_TVNCONTROL),
MB_OK | MB_ICONERROR);
}
return 1;
} // try / catch.
return 0;
}
Configurator *configurator = Configurator::getInstance();
configurator->setServiceFlag(configService);
configurator->load();
ConfigDialog confDialog(configService, 0);
return confDialog.showModal();
}
示例14: demoMyType1Collection
void demoMyType1Collection(const Configurator& configurator)
{
//
// Collection configuration example
//
// First way is to manually iterate over and second way to to use insert_iterator
//
auto iter = configurator.get<MyType1>("object.MyType1");
while ( iter )
{
cout << *iter << endl;
++iter;
}
//
// Second way to to use insert_iterator
//
vector<MyType1> values;
cout << "Number of configured objects: " << configurator.get("object.MyType1", back_inserter(values)) << endl;
for (const auto& value: values)
{
cout << value << endl;
}
}
示例15: sessionPhase
void RfbInitializer::sessionPhase()
{
Configurator *conf = Configurator::getInstance();
ServerConfig *srvConf = conf->getServerConfig();
unsigned int id = srvConf->getLastSessionId();
m_input->readUTF8(&m_organization);
m_output->writeUInt32(id);
m_sessionId = m_input->readUInt32();
if (m_sessionId != id) {
srvConf->setLastSessionId(m_sessionId);
conf->save();
}
}