本文整理汇总了C++中PropertiesPtr::getProperty方法的典型用法代码示例。如果您正苦于以下问题:C++ PropertiesPtr::getProperty方法的具体用法?C++ PropertiesPtr::getProperty怎么用?C++ PropertiesPtr::getProperty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PropertiesPtr
的用法示例。
在下文中一共展示了PropertiesPtr::getProperty方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createProperties
Ice::PropertiesPtr
IceBox::ServiceManagerI::createServiceProperties(const string& service)
{
PropertiesPtr properties;
PropertiesPtr communicatorProperties = _communicator->getProperties();
if(communicatorProperties->getPropertyAsInt("IceBox.InheritProperties") > 0)
{
properties = communicatorProperties->clone();
properties->setProperty("Ice.Admin.Endpoints", ""); // Inherit all except Ice.Admin.Endpoints!
}
else
{
properties = createProperties();
}
string programName = communicatorProperties->getProperty("Ice.ProgramName");
if(programName.empty())
{
properties->setProperty("Ice.ProgramName", service);
}
else
{
properties->setProperty("Ice.ProgramName", programName + "-" + service);
}
return properties;
}
示例2: if
Glacier2::FilterManagerPtr
Glacier2::FilterManager::create(const InstancePtr& instance, const string& userId, const bool allowAddUser)
{
PropertiesPtr props = instance->properties();
string allow = props->getProperty("Glacier2.Filter.Category.Accept");
vector<string> allowSeq;
stringToSeq(allow, allowSeq);
if(allowAddUser)
{
int addUserMode = 0;
if(!props->getProperty("Glacier2.Filter.Category.AcceptUser").empty())
{
addUserMode = props->getPropertyAsInt("Glacier2.Filter.Category.AcceptUser");
}
if(addUserMode > 0 && !userId.empty())
{
if(addUserMode == 1)
{
allowSeq.push_back(userId); // Add user id to allowed categories.
}
else if(addUserMode == 2)
{
allowSeq.push_back('_' + userId); // Add user id with prepended underscore to allowed categories.
}
}
}
Glacier2::StringSetIPtr categoryFilter = new Glacier2::StringSetI(allowSeq);
//
// TODO: refactor initialization of filters.
//
allow = props->getProperty("Glacier2.Filter.AdapterId.Accept");
stringToSeq(allow, allowSeq);
Glacier2::StringSetIPtr adapterIdFilter = new Glacier2::StringSetI(allowSeq);
//
// TODO: Object id's from configurations?
//
IdentitySeq allowIdSeq;
allow = props->getProperty("Glacier2.Filter.Identity.Accept");
stringToSeq(instance->communicator(), allow, allowIdSeq);
Glacier2::IdentitySetIPtr identityFilter = new Glacier2::IdentitySetI(allowIdSeq);
return new Glacier2::FilterManager(instance, categoryFilter, adapterIdFilter, identityFilter);
}
示例3: getDataDir
std::string ServiceManagerI::getDataDir()
{
PropertiesPtr props =
mAdapter->getCommunicator()->getProperties();
getVLogger().setLocalVerbosityLevel(props->getProperty("CVAC.ServicesVerbosity"));
// Load the CVAC property: 'CVAC.DataDir'. Used for the xml filename path,
// and to provide a prefix to Runset paths
std::string dataDir = props->getProperty("CVAC.DataDir");
if(dataDir.empty())
{
localAndClientMsg(VLogger::WARN, NULL,
"Unable to locate CVAC Data directory, specified: "
"'CVAC.DataDir = path/to/dataDir' in config.service\n");
}
localAndClientMsg(VLogger::DEBUG, NULL,
"CVAC Data directory configured as: %s \n", dataDir.c_str());
return dataDir;
}
示例4: init
IcePatch2::Patcher::Patcher(const CommunicatorPtr& communicator, const PatcherFeedbackPtr& feedback) :
_feedback(feedback),
_dataDir(getDataDir(communicator, ".")),
_thorough(getThorough(communicator, 0) > 0),
_chunkSize(getChunkSize(communicator, 100)),
_remove(getRemove(communicator, 1)),
_log(0)
{
const PropertiesPtr properties = communicator->getProperties();
const char* clientProxyProperty = "IcePatch2Client.Proxy";
std::string clientProxy = properties->getProperty(clientProxyProperty);
if(clientProxy.empty())
{
const char* endpointsProperty = "IcePatch2.Endpoints";
string endpoints = properties->getProperty(endpointsProperty);
if(endpoints.empty())
{
ostringstream os;
os << "No proxy to IcePatch2 server. Please set `" << clientProxyProperty
<< "' or `" << endpointsProperty << "'.";
throw os.str();
}
ostringstream os;
os << "The property " << endpointsProperty << " is deprecated, use " << clientProxyProperty << " instead.";
communicator->getLogger()->warning(os.str());
Identity id;
id.category = properties->getPropertyWithDefault("IcePatch2.InstanceName", "IcePatch2");
id.name = "server";
clientProxy = "\"" + communicator->identityToString(id) + "\" :" + endpoints;
}
ObjectPrx serverBase = communicator->stringToProxy(clientProxy);
FileServerPrx server = FileServerPrx::checkedCast(serverBase);
if(!server)
{
throw "proxy `" + clientProxy + "' is not a file server.";
}
init(server);
}
示例5: newCallback
IceBox::ServiceManagerI::ServiceManagerI(CommunicatorPtr communicator, int& argc, char* argv[]) :
_communicator(communicator),
_adminEnabled(false),
_pendingStatusChanges(false),
_traceServiceObserver(0)
{
#ifndef ICE_CPP11_MAPPING
const_cast<CallbackPtr&>(_observerCompletedCB) = newCallback(this, &ServiceManagerI::observerCompleted);
#endif
_logger = _communicator->getLogger();
PropertiesPtr props = _communicator->getProperties();
_traceServiceObserver = props->getPropertyAsInt("IceBox.Trace.ServiceObserver");
if(props->getProperty("Ice.Admin.Enabled") == "")
{
_adminEnabled = props->getProperty("Ice.Admin.Endpoints") != "";
}
else
{
_adminEnabled = props->getPropertyAsInt("Ice.Admin.Enabled") > 0;
}
if(_adminEnabled)
{
StringSeq facetSeq = props->getPropertyAsList("Ice.Admin.Facets");
if(!facetSeq.empty())
{
_adminFacetFilter.insert(facetSeq.begin(), facetSeq.end());
}
}
for(int i = 1; i < argc; i++)
{
_argv.push_back(argv[i]);
}
}
示例6: getModelFileFromConfig
// look for ServiceNamex.TrainedModel
// Note that the x is significant
string ServiceManagerI::getModelFileFromConfig()
{
CommunicatorPtr comm = mAdapter->getCommunicator();
if ( comm )
{
PropertiesPtr props = comm->getProperties();
if (props==true)
{
string propname = mServiceName + "x.TrainedModel";
string propval = props->getProperty( propname );
return propval;
}
}
return "";
}
示例7: catch
int
run(int, char* argv[], const CommunicatorPtr& communicator)
{
PropertiesPtr properties = communicator->getProperties();
const char* managerProxyProperty = "IceStormAdmin.TopicManager.Default";
string managerProxy = properties->getProperty(managerProxyProperty);
if(managerProxy.empty())
{
cerr << argv[0] << ": property `" << managerProxyProperty << "' is not set" << endl;
return EXIT_FAILURE;
}
IceStorm::TopicManagerPrx manager = IceStorm::TopicManagerPrx::checkedCast(
communicator->stringToProxy(managerProxy));
if(!manager)
{
cerr << argv[0] << ": `" << managerProxy << "' is not running" << endl;
return EXIT_FAILURE;
}
TopicPrx topic;
try
{
topic = manager->retrieve("single");
}
catch(const NoSuchTopic& e)
{
cerr << argv[0] << ": NoSuchTopic: " << e.name << endl;
return EXIT_FAILURE;
}
assert(topic);
//
// Get a publisher object, create a twoway proxy and then cast to
// a Single object.
//
SinglePrx single = SinglePrx::uncheckedCast(topic->getPublisher()->ice_twoway());
for(int i = 0; i < 1000; ++i)
{
single->event(i);
}
return EXIT_SUCCESS;
}
示例8: if
void
IceServiceInstaller::install(const PropertiesPtr& properties)
{
_debug = properties->getPropertyAsInt("Debug") != 0;
initializeSid(properties->getPropertyWithDefault("ObjectName", "NT Authority\\LocalService"));
const string defaultDisplayName[] =
{
"IceGrid registry (" + _icegridInstanceName + ")",
"IceGrid node (" + _nodeName + " within " + _icegridInstanceName + ")",
"Glacier2 router (" + _glacier2InstanceName + ")"
};
const string defaultDescription[] =
{
"Location and deployment service for Ice applications",
"Starts and monitors Ice servers",
"Ice Firewall traversal service"
};
string displayName = properties->getPropertyWithDefault("DisplayName", defaultDisplayName[_serviceType]);
string description = properties->getPropertyWithDefault("Description", defaultDescription[_serviceType]);
string imagePath = properties->getProperty("ImagePath");
if(imagePath == "")
{
char buffer[MAX_PATH];
DWORD size = GetModuleFileName(0, buffer, MAX_PATH);
if(size == 0)
{
throw "Can't get full path to self: " + IceUtilInternal::errorToString(GetLastError());
}
imagePath = string(buffer, size);
imagePath.replace(imagePath.rfind('\\'), string::npos, "\\" + serviceTypeToLowerString(_serviceType) + ".exe");
}
else
{
imagePath = fixDirSeparator(imagePath);
}
if(!fileExists(imagePath))
{
throw imagePath + ": not found";
}
string dependency;
if(_serviceType == icegridregistry)
{
if(properties->getPropertyAsInt("DependOnRegistry") != 0)
{
throw "The IceGrid registry service can't depend on itself";
}
string registryDataDir = fixDirSeparator(_serviceProperties->getProperty("IceGrid.Registry.Data"));
if(registryDataDir == "")
{
throw "IceGrid.Registry.Data must be set in " + _configFile;
}
if(!IceUtilInternal::isAbsolutePath(registryDataDir))
{
throw "'" + registryDataDir + "' is a relative path; IceGrid.Registry.Data must be an absolute path";
}
if(!mkdir(registryDataDir))
{
grantPermissions(registryDataDir, SE_FILE_OBJECT, true, true);
}
}
else if(_serviceType == icegridnode)
{
string nodeDataDir = fixDirSeparator(_serviceProperties->getProperty("IceGrid.Node.Data"));
if(nodeDataDir == "")
{
throw "IceGrid.Node.Data must be set in " + _configFile;
}
if(!IceUtilInternal::isAbsolutePath(nodeDataDir))
{
throw "'" + nodeDataDir + "' is a relative path; IceGrid.Node.Data must be an absolute path";
}
if(!mkdir(nodeDataDir))
{
grantPermissions(nodeDataDir, SE_FILE_OBJECT, true, true);
}
grantPermissions("MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Perflib", SE_REGISTRY_KEY, true);
if(properties->getPropertyAsInt("DependOnRegistry") != 0)
{
dependency = "icegridregistry." + _icegridInstanceName;
}
}
else if(_serviceType == glacier2router)
{
if(properties->getPropertyAsInt("DependOnRegistry") != 0)
{
if(_icegridInstanceName == "")
{
throw "Ice.Default.Locator must be set in " + _configFile + " when DependOnRegistry is not zero";
}
//.........这里部分代码省略.........
示例9: is
instanceName = opts.optArg("instanceName");
}
int port = communicator()->getProperties()->getPropertyAsInt("IceGridAdmin.Port");
if(!opts.optArg("port").empty())
{
istringstream is(opts.optArg("port"));
if(!(is >> port))
{
cerr << _appName << ": given port number is not a numeric value" << endl;
return EXIT_FAILURE;
}
}
PropertiesPtr properties = communicator()->getProperties();
string replica = properties->getProperty("IceGridAdmin.Replica");
if(!opts.optArg("replica").empty())
{
replica = opts.optArg("replica");
}
Glacier2::RouterPrx router;
AdminSessionPrx session;
SessionKeepAliveThreadPtr keepAlive;
int status = EXIT_SUCCESS;
try
{
int sessionTimeout;
int acmTimeout = 0;
if(!communicator()->getDefaultLocator() && !communicator()->getDefaultRouter())
{
示例10: process
void CascadeTrainI::process(const Identity &client, const RunSet& runset,
const TrainerProperties& trainProps,
const Current& current)
{
mTrainProps->load(trainProps);
// Obtain CVAC verbosity - TODO: this should happen earlier
PropertiesPtr svcprops = current.adapter->getCommunicator()->getProperties();
string verbStr = svcprops->getProperty("CVAC.ServicesVerbosity");
if (!verbStr.empty())
{
getVLogger().setLocalVerbosityLevel( verbStr );
}
TrainerCallbackHandlerPrx callback =
TrainerCallbackHandlerPrx::uncheckedCast(current.con->createProxy(client)->ice_oneway());
if (mTrainProps->hasInfoFile == false)
{
// check the validity of the runset.
if (!checkPurposedLists( runset.purposedLists, callback ))
return;
}
// Get the remote client name to use to save cascade file
std::string connectName = cvac::getClientConnectionName(current);
const std::string CVAC_DataDir = svcprops->getProperty("CVAC.DataDir");
if(runset.purposedLists.size() == 0 && mTrainProps->hasInfoFile == false)
{
string _resStr = "Error: no data (runset) for processing\n";
localAndClientMsg(VLogger::WARN, callback, _resStr.c_str());
return;
}
// Since createSamples fails if there is a space in a file name we will create a temporary runset
// and provide symbolic links to files that name spaces in there names.
//cvac::RunSet tempRunSet = runset;
// Add the cvac data dir to the directories in the runset
//addDataPath(tempRunSet, CVAC_DataDir);
// The symbolic links are created in a tempdir so lets remember it so we can delete it at the end
//std::string tempRSDir = fixupRunSet(tempRunSet, CVAC_DataDir);
// Iterate over runset, inserting each POSITIVE Labelable into
// the input file to "createsamples". Add each NEGATIVE into
// the bgFile. Put both created files into a tempdir.
std::string clientName = mServiceMan->getSandbox()->createClientName(mServiceMan->getServiceName(),
connectName);
std::string tempDir = mServiceMan->getSandbox()->createTrainingDir(clientName);
//RunSetWrapper rsw( &tempRunSet, CVAC_DataDir, mServiceMan );
RunSetWrapper rsw( &runset, CVAC_DataDir, mServiceMan );
// We can't put the bgName and infoName in the tempdir without
// changing cvSamples since it assumes that this files location is the root
// directory for the data.
//string bgName = tempDir + "/cascade_negatives.txt";
//string infoName = tempDir + "/cascade_positives.txt";
string bgName = "cascade_negatives.txt";
string infoName = "cascade_positives.txt";
if (mTrainProps->hasInfoFile)
infoName = mTrainProps->infoFile;
int numNeg = 0;
writeBgFile( rsw, bgName, &numNeg, CVAC_DataDir, callback );
// set parameters to createsamples
SamplesParams samplesParams;
samplesParams.numSamples = 1000;
if (mTrainProps->sampleSize.width != 0)
samplesParams.width = mTrainProps->sampleSize.width;
else
samplesParams.width = mTrainProps->windowSize.width;
if (mTrainProps->sampleSize.height != 0)
samplesParams.height = mTrainProps->sampleSize.height;
else
samplesParams.height = mTrainProps->windowSize.height;
// run createsamples
std::string vecFname = tempDir + "/cascade_positives.vec";
int numPos = 0;
createSamples( rsw, samplesParams, infoName, vecFname, &numPos, CVAC_DataDir, callback,
bgName, numNeg);
// Tell ServiceManager that we will listen for stop
mServiceMan->setStoppable();
bool created = createClassifier( tempDir, vecFname, bgName,
numPos, numNeg, mTrainProps );
// Tell ServiceManager that we are done listening for stop
mServiceMan->clearStop();
if (created)
{
DetectorDataArchive dda;
std::string clientDir = mServiceMan->getSandbox()->createClientDir(clientName);
std::string archiveFilename = getDateFilename(clientDir, "cascade")+ ".zip";
dda.setArchiveFilename(archiveFilename);
dda.addFile(XMLID, tempDir + "/cascade.xml");
dda.createArchive(tempDir);
mServiceMan->getSandbox()->deleteTrainingDir(clientName);
//.........这里部分代码省略.........
示例11: if
IceInternal::DefaultsAndOverrides::DefaultsAndOverrides(const PropertiesPtr& properties) :
overrideTimeout(false),
overrideTimeoutValue(-1),
overrideConnectTimeout(false),
overrideConnectTimeoutValue(-1),
overrideCloseTimeout(false),
overrideCloseTimeoutValue(-1),
overrideCompress(false),
overrideCompressValue(false),
overrideSecure(false),
overrideSecureValue(false)
{
const_cast<string&>(defaultProtocol) = properties->getPropertyWithDefault("Ice.Default.Protocol", "tcp");
const_cast<string&>(defaultHost) = properties->getProperty("Ice.Default.Host");
string value;
value = properties->getProperty("Ice.Override.Timeout");
if(!value.empty())
{
const_cast<bool&>(overrideTimeout) = true;
const_cast<Int&>(overrideTimeoutValue) = properties->getPropertyAsInt("Ice.Override.Timeout");
}
value = properties->getProperty("Ice.Override.ConnectTimeout");
if(!value.empty())
{
const_cast<bool&>(overrideConnectTimeout) = true;
const_cast<Int&>(overrideConnectTimeoutValue) = properties->getPropertyAsInt("Ice.Override.ConnectTimeout");
}
value = properties->getProperty("Ice.Override.CloseTimeout");
if(!value.empty())
{
const_cast<bool&>(overrideCloseTimeout) = true;
const_cast<Int&>(overrideCloseTimeoutValue) = properties->getPropertyAsInt("Ice.Override.CloseTimeout");
}
value = properties->getProperty("Ice.Override.Compress");
if(!value.empty())
{
const_cast<bool&>(overrideCompress) = true;
const_cast<bool&>(overrideCompressValue) = properties->getPropertyAsInt("Ice.Override.Compress");
}
value = properties->getProperty("Ice.Override.Secure");
if(!value.empty())
{
const_cast<bool&>(overrideSecure) = true;
const_cast<bool&>(overrideSecureValue) = properties->getPropertyAsInt("Ice.Override.Secure");
}
const_cast<bool&>(defaultCollocationOptimization) =
properties->getPropertyAsIntWithDefault("Ice.Default.CollocationOptimized", 1) > 0;
value = properties->getPropertyWithDefault("Ice.Default.EndpointSelection", "Random");
if(value == "Random")
{
defaultEndpointSelection = Random;
}
else if(value == "Ordered")
{
defaultEndpointSelection = Ordered;
}
else
{
EndpointSelectionTypeParseException ex(__FILE__, __LINE__);
ex.str = "illegal value `" + value + "'; expected `Random' or `Ordered'";
throw ex;
}
const_cast<int&>(defaultLocatorCacheTimeout) =
properties->getPropertyAsIntWithDefault("Ice.Default.LocatorCacheTimeout", -1);
const_cast<bool&>(defaultPreferSecure) =
properties->getPropertyAsIntWithDefault("Ice.Default.PreferSecure", 0) > 0;
value = properties->getPropertyWithDefault("Ice.Default.EncodingVersion", encodingVersionToString(currentEncoding));
defaultEncoding = stringToEncodingVersion(value);
checkSupportedEncoding(defaultEncoding);
bool slicedFormat = properties->getPropertyAsIntWithDefault("Ice.Default.SlicedFormat", 0) > 0;
const_cast<FormatType&>(defaultFormat) = slicedFormat ? SlicedFormat : CompactFormat;
}
示例12: ex
bool
IceBox::ServiceManagerI::start()
{
try
{
ServiceManagerPtr obj = this;
PropertiesPtr properties = _communicator->getProperties();
//
// Create an object adapter. Services probably should NOT share
// this object adapter, as the endpoint(s) for this object adapter
// will most likely need to be firewalled for security reasons.
//
ObjectAdapterPtr adapter;
if(properties->getProperty("IceBox.ServiceManager.Endpoints") != "")
{
adapter = _communicator->createObjectAdapter("IceBox.ServiceManager");
Identity identity;
identity.category = properties->getPropertyWithDefault("IceBox.InstanceName", "IceBox");
identity.name = "ServiceManager";
adapter->add(obj, identity);
}
//
// Parse the property set with the prefix "IceBox.Service.". These
// properties should have the following format:
//
// IceBox.Service.Foo=entry_point [args]
//
// We parse the service properties specified in IceBox.LoadOrder
// first, then the ones from remaining services.
//
const string prefix = "IceBox.Service.";
PropertyDict services = properties->getPropertiesForPrefix(prefix);
PropertyDict::iterator p;
StringSeq loadOrder = properties->getPropertyAsList("IceBox.LoadOrder");
vector<StartServiceInfo> servicesInfo;
for(StringSeq::const_iterator q = loadOrder.begin(); q != loadOrder.end(); ++q)
{
p = services.find(prefix + *q);
if(p == services.end())
{
FailureException ex(__FILE__, __LINE__);
ex.reason = "ServiceManager: no service definition for `" + *q + "'";
throw ex;
}
servicesInfo.push_back(StartServiceInfo(*q, p->second, _argv));
services.erase(p);
}
for(p = services.begin(); p != services.end(); ++p)
{
servicesInfo.push_back(StartServiceInfo(p->first.substr(prefix.size()), p->second, _argv));
}
//
// Check if some services are using the shared communicator in which
// case we create the shared communicator now with a property set which
// is the union of all the service properties (services which are using
// the shared communicator).
//
PropertyDict sharedCommunicatorServices = properties->getPropertiesForPrefix("IceBox.UseSharedCommunicator.");
if(!sharedCommunicatorServices.empty())
{
InitializationData initData;
initData.properties = createServiceProperties("SharedCommunicator");
for(vector<StartServiceInfo>::iterator q = servicesInfo.begin(); q != servicesInfo.end(); ++q)
{
if(properties->getPropertyAsInt("IceBox.UseSharedCommunicator." + q->name) <= 0)
{
continue;
}
//
// Load the service properties using the shared communicator properties as
// the default properties.
//
PropertiesPtr svcProperties = createProperties(q->args, initData.properties);
//
// Erase properties from the shared communicator which don't exist in the
// service properties (which include the shared communicator properties
// overriden by the service properties).
//
PropertyDict allProps = initData.properties->getPropertiesForPrefix("");
for(PropertyDict::iterator p = allProps.begin(); p != allProps.end(); ++p)
{
if(svcProperties->getProperty(p->first) == "")
{
initData.properties->setProperty(p->first, "");
}
}
//
// Add the service properties to the shared communicator properties.
//
PropertyDict props = svcProperties->getPropertiesForPrefix("");
for(PropertyDict::const_iterator r = props.begin(); r != props.end(); ++r)
{
initData.properties->setProperty(r->first, r->second);
//.........这里部分代码省略.........
示例13: err
bool
RouterService::start(int argc, char* argv[], int& status)
{
bool nowarn;
IceUtilInternal::Options opts;
opts.addOpt("h", "help");
opts.addOpt("v", "version");
opts.addOpt("", "nowarn");
vector<string> args;
try
{
args = opts.parse(argc, const_cast<const char**>(argv));
}
catch(const IceUtilInternal::BadOptException& e)
{
error(e.reason);
usage(argv[0]);
return false;
}
if(opts.isSet("help"))
{
usage(argv[0]);
status = EXIT_SUCCESS;
return false;
}
if(opts.isSet("version"))
{
print(ICE_STRING_VERSION);
status = EXIT_SUCCESS;
return false;
}
nowarn = opts.isSet("nowarn");
if(!args.empty())
{
consoleErr << argv[0] << ": too many arguments" << endl;
usage(argv[0]);
return false;
}
PropertiesPtr properties = communicator()->getProperties();
//
// Initialize the client object adapter.
//
const string clientEndpointsProperty = "Glacier2.Client.Endpoints";
if(properties->getProperty(clientEndpointsProperty).empty())
{
error("property `" + clientEndpointsProperty + "' is not set");
return false;
}
if(properties->getPropertyAsInt("Glacier2.SessionTimeout") > 0 &&
properties->getProperty("Glacier2.Client.ACM.Timeout").empty())
{
ostringstream os;
os << properties->getPropertyAsInt("Glacier2.SessionTimeout");
properties->setProperty("Glacier2.Client.ACM.Timeout", os.str());
}
if(properties->getProperty("Glacier2.Client.ACM.Close").empty())
{
properties->setProperty("Glacier2.Client.ACM.Close", "4"); // Forcefull close on invocation and idle.
}
ObjectAdapterPtr clientAdapter = communicator()->createObjectAdapter("Glacier2.Client");
//
// Initialize the server object adapter only if server endpoints
// are defined.
//
const string serverEndpointsProperty = "Glacier2.Server.Endpoints";
ObjectAdapterPtr serverAdapter;
if(!properties->getProperty(serverEndpointsProperty).empty())
{
serverAdapter = communicator()->createObjectAdapter("Glacier2.Server");
}
string instanceName = communicator()->getProperties()->getPropertyWithDefault("Glacier2.InstanceName", "Glacier2");
vector<string> verifierProperties;
verifierProperties.push_back("Glacier2.PermissionsVerifier");
verifierProperties.push_back("Glacier2.SSLPermissionsVerifier");
Glacier2Internal::setupNullPermissionsVerifier(communicator(), instanceName, verifierProperties);
string verifierProperty = verifierProperties[0];
PermissionsVerifierPrx verifier;
ObjectPrx obj;
try
{
//
// We use propertyToProxy instead of stringToProxy because the property
// can provide proxy attributes
//
obj = communicator()->propertyToProxy(verifierProperty);
}
//.........这里部分代码省略.........
示例14: initialize
bowCV* BowICETrainI::initialize( TrainerCallbackHandlerPrx& _callback,
const TrainerProperties &tprops,
DetectorDataArchive& dda,
const Current& current )
{
// Set CVAC verbosity according to ICE properties
PropertiesPtr iceprops =
(current.adapter->getCommunicator()->getProperties());
string verbStr = iceprops->getProperty("CVAC.ServicesVerbosity");
if (!verbStr.empty())
{
vLogger.setLocalVerbosityLevel( verbStr );
}
// defaults
//SURF, SIFT, FAST, STAR, MSER, GFTT, HARRIS
string _nameFeature("SIFT");
//SURF, SIFT, OpponentSIFT, OpponentSURF
string _nameDescriptor("SIFT");
//BruteForce-L1, BruteForce, FlannBased
string _nameMatcher("BruteForce-L1");
int _countWords = 150;
// read properties; need to cast const away
cvac::Properties& trp = (cvac::Properties&) tprops.props;
const string& nf = trp[bowCV::BOW_DETECTOR_NAME];
if (!nf.empty())
{
_nameFeature = nf;
localAndClientMsg(VLogger::DEBUG, _callback,
"Set FeatureType to %s\n", nf.c_str() );
}
const string& nd = trp[bowCV::BOW_EXTRACTOR_NAME];
if (!nd.empty())
{
_nameDescriptor = nd;
localAndClientMsg(VLogger::DEBUG, _callback,
"Set DescriptorType to %s\n", nd.c_str() );
}
const string& nm = trp[bowCV::BOW_MATCHER_NAME];
if (!nm.empty())
{
_nameMatcher = nm;
localAndClientMsg(VLogger::DEBUG, _callback,
"Set MatcherType to %s\n", nm.c_str() );
}
const string& nw = trp["NumWords"];
if (!nw.empty())
{
errno=0;
long int cw = (int) strtol( nw.c_str(), (char**) NULL, 10 );
if (cw>0 && cw<INT_MAX && errno==0)
{
// no error, successfully parsed int from NumWords property
_countWords = cw;
localAndClientMsg(VLogger::DEBUG, _callback,
"Number of words set to %d\n", cw );
}
}
// figure out how to handle Negative purpose samples, if any
const string& strategy = trp[bowCV::BOW_REJECT_CLASS_STRATEGY];
if (!strategy.empty())
{
std::string strat = strategy;
std::transform( strategy.begin(), strategy.end(), strat.begin(), ::tolower );
rejectClassStrategy = bowCV::BOW_REJECT_CLASS_AS_MULTICLASS;
if (0==strat.compare(bowCV::BOW_REJECT_CLASS_IGNORE_SAMPLES))
{
rejectClassStrategy = bowCV::BOW_REJECT_CLASS_IGNORE_SAMPLES;
localAndClientMsg(VLogger::DEBUG, _callback,
"BOW will ignore any samples with Negative purpose\n");
}
else if (0==strat.compare(bowCV::BOW_REJECT_CLASS_AS_MULTICLASS))
{
rejectClassStrategy = bowCV::BOW_REJECT_CLASS_AS_MULTICLASS;
localAndClientMsg(VLogger::DEBUG, _callback,
"BOW will treat samples with Negative purpose as a separate class\n");
}
else if (0==strat.compare(bowCV::BOW_REJECT_CLASS_AS_FIRST_STAGE))
{
rejectClassStrategy = bowCV::BOW_REJECT_CLASS_AS_FIRST_STAGE;
localAndClientMsg(VLogger::DEBUG, _callback,
"BOW will create a two-stage classifier: reject first, multiclass second\n");
localAndClientMsg(VLogger::ERROR, _callback,
"BOW two-stage classifier is not implemented yet\n");
return false;
}
else
{
localAndClientMsg(VLogger::WARN, _callback,
"Incorrect specifier for %s property, using default (%s).\n",
bowCV::BOW_REJECT_CLASS_STRATEGY.c_str(), rejectClassStrategy.c_str() );
}
}
bowCV* pBowCV = new bowCV(this);
bool fInitialized =
pBowCV->train_initialize(_nameFeature,_nameDescriptor,_nameMatcher,_countWords, &dda);
if (fInitialized)
//.........这里部分代码省略.........
示例15: if
bool
NodeService::startImpl(int argc, char* argv[], int& status)
{
bool nowarn = false;
bool readonly = false;
string initFromReplica;
string desc;
vector<string> targets;
for(int i = 1; i < argc; ++i)
{
if(strcmp(argv[i], "-h") == 0 || strcmp(argv[i], "--help") == 0)
{
usage(argv[0]);
status = EXIT_SUCCESS;
return false;
}
else if(strcmp(argv[i], "-v") == 0 || strcmp(argv[i], "--version") == 0)
{
print(ICE_STRING_VERSION);
status = EXIT_SUCCESS;
return false;
}
else if(strcmp(argv[i], "--nowarn") == 0)
{
nowarn = true;
}
else if(strcmp(argv[i], "--readonly") == 0)
{
readonly = true;
}
else if(strcmp(argv[i], "--initdb-from-replica") == 0)
{
if(i + 1 >= argc)
{
error("missing replica argument for option `" + string(argv[i]) + "'");
usage(argv[0]);
return false;
}
initFromReplica = argv[++i];
}
else if(strcmp(argv[i], "--deploy") == 0)
{
if(i + 1 >= argc)
{
error("missing descriptor argument for option `" + string(argv[i]) + "'");
usage(argv[0]);
return false;
}
desc = argv[++i];
while(i + 1 < argc && argv[++i][0] != '-')
{
targets.push_back(argv[i]);
}
}
else
{
error("invalid option: `" + string(argv[i]) + "'");
usage(argv[0]);
return false;
}
}
PropertiesPtr properties = communicator()->getProperties();
//
// Disable server idle time. Otherwise, the adapter would be
// shutdown prematurely and the deactivation would fail.
// Deactivation of the node relies on the object adapter
// to be active since it needs to terminate servers.
//
// TODO: implement Ice.ServerIdleTime in the activator
// termination listener instead?
//
properties->setProperty("Ice.ServerIdleTime", "0");
//
// Warn the user that setting Ice.ThreadPool.Server isn't useful.
//
if(!nowarn && properties->getPropertyAsIntWithDefault("Ice.ThreadPool.Server.Size", 0) > 0)
{
Warning out(communicator()->getLogger());
out << "setting `Ice.ThreadPool.Server.Size' is not useful, ";
out << "you should set individual adapter thread pools instead.";
}
setupThreadPool(properties, "IceGrid.Node.ThreadPool", 1, 100);
//
// Create the activator.
//
TraceLevelsPtr traceLevels = new TraceLevels(communicator(), "IceGrid.Node");
_activator = new Activator(traceLevels);
//
// Collocate the IceGrid registry if we need to.
//.........这里部分代码省略.........