本文整理汇总了C++中ice::StringSeq::empty方法的典型用法代码示例。如果您正苦于以下问题:C++ StringSeq::empty方法的具体用法?C++ StringSeq::empty怎么用?C++ StringSeq::empty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ice::StringSeq
的用法示例。
在下文中一共展示了StringSeq::empty方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: init
bool AgentAdapter::init(const ::Ice::StringSeq& defaultAgents,const bool is_udp_protocol, const bool is_compress)
{
if (defaultAgents.empty())
{
XLOG_ERROR("AgentAdapter::init defaultAgent is empty!");
return false;
}
srand(unsigned(time(NULL)));
Ice::PropertiesPtr props=Ice::createProperties();
props->setProperty("Ice.MessageSizeMax", ICE_MESSAGE_SIZE_MAX);
props->setProperty("Ice.Override.Timeout", ICE_TIMEOUT_MILLISECONDS);
Ice::InitializationData id;
id.properties=props;
_ic = ::Ice::initialize(id);
srand((unsigned) time(NULL));
current_agent_prx_number=0;
std::vector<slice::AgentPrx> _prxs;
for (::Ice::StringSeq::const_iterator it = defaultAgents.begin(); it != defaultAgents.end();
++it)
{
slice::AgentPrx prx = Util::getPrx<slice::AgentPrx>(_ic, *it, is_udp_protocol, 1000, is_compress);
_prxs.push_back(prx);
}
agent_prxs.swap(_prxs);
return true;
}
示例2: lock
void
LibraryI::remove(const BookDescription& description)
{
IceUtil::Mutex::Lock lock(*this);
//
// Note: no need to catch and retry on deadlock since all access to
// _authors is serialized.
//
try
{
StringIsbnSeqDict::iterator p = _authors.find(description.authors);
assert(p != _authors.end());
//
// Remove the isbn number from the sequence.
//
Ice::StringSeq isbnSeq = p->second;
isbnSeq.erase(remove_if(isbnSeq.begin(), isbnSeq.end(), bind2nd(equal_to<string>(), description.isbn)),
isbnSeq.end());
if(isbnSeq.empty())
{
//
// If there are no further associated isbn numbers then remove
// the record.
//
_authors.erase(p);
}
else
{
//
// Otherwise, write back the new record.
//
p.set(isbnSeq);
}
//
// This can throw EvictorDeactivatedException (which indicates
// an internal error). The exception is currently ignored.
//
_evictor->remove(createBookIdentity(description.isbn));
}
catch(const Freeze::DatabaseException& ex)
{
DatabaseException e;
e.message = ex.message;
throw e;
}
}
示例3: string
int
Activator::activate(const string& name,
const string& exePath,
const string& pwdPath,
#ifndef _WIN32
uid_t uid,
gid_t gid,
#endif
const Ice::StringSeq& options,
const Ice::StringSeq& envs,
const ServerIPtr& server)
{
IceUtil::Monitor< IceUtil::Mutex>::Lock sync(*this);
if(_deactivating)
{
throw string("The node is being shutdown.");
}
string path = exePath;
if(path.empty())
{
throw string("The server executable path is empty.");
}
string pwd = IcePatch2Internal::simplify(pwdPath);
#ifdef _WIN32
if(!IceUtilInternal::isAbsolutePath(path))
{
if(path.find('/') == string::npos)
{
//
// Get the absolute pathname of the executable.
//
wchar_t absbuf[_MAX_PATH];
wchar_t* fPart;
wstring ext = path.size() <= 4 || path[path.size() - 4] != '.' ? L".exe" : L"";
//
// IceGrid doesn't support to use string converters, so don't need to use
// any string converter in wstringToString conversions.
//
if(SearchPathW(NULL, IceUtil::stringToWstring(path).c_str(), ext.c_str(), _MAX_PATH, absbuf, &fPart) == 0)
{
if(_traceLevels->activator > 0)
{
Trace out(_traceLevels->logger, _traceLevels->activatorCat);
out << "couldn't find `" << path << "' executable.";
}
throw string("Couldn't find `" + path + "' executable.");
}
path = IceUtil::wstringToString(absbuf);
}
else if(!pwd.empty())
{
path = pwd + "/" + path;
}
}
//
// Get the absolute pathname of the working directory.
//
// IceGrid doesn't support to use string converters, so
// don't need to use any string converter in stringToWstring
// conversions.
//
if(!pwd.empty())
{
wchar_t absbuf[_MAX_PATH];
if(_wfullpath(absbuf, IceUtil::stringToWstring(pwd).c_str(), _MAX_PATH) == NULL)
{
if(_traceLevels->activator > 0)
{
Trace out(_traceLevels->logger, _traceLevels->activatorCat);
out << "cannot convert `" << pwd << "' into an absolute path";
}
throw string("The server working directory path `" + pwd + "' can't be converted into an absolute path.");
}
pwd = IceUtil::wstringToString(absbuf);
}
#endif
//
// Setup arguments.
//
StringSeq args;
args.push_back(path);
args.insert(args.end(), options.begin(), options.end());
if(_traceLevels->activator > 0)
{
Ice::Trace out(_traceLevels->logger, _traceLevels->activatorCat);
out << "activating server `" << name << "'";
if(_traceLevels->activator > 1)
{
out << "\n";
out << "path = " << path << "\n";
if(pwd.empty())
{
string cwd;
//.........这里部分代码省略.........
示例4: test
void
allTests(const Ice::CommunicatorPtr& communicator)
{
string ref = "DemoIceBox/admin:default -p 9996 -t 10000";
Ice::ObjectPrx admin = communicator->stringToProxy(ref);
TestFacetPrx facet;
cout << "testing custom facet... " << flush;
{
//
// Test: Verify that the custom facet is present.
//
facet = Test::TestFacetPrx::checkedCast(admin, "TestFacet");
facet->ice_ping();
}
cout << "ok" << endl;
cout << "testing properties facet... " << flush;
{
Ice::PropertiesAdminPrx pa =
Ice::PropertiesAdminPrx::checkedCast(admin, "IceBox.Service.TestService.Properties");
//
// Test: PropertiesAdmin::getProperty()
//
test(pa->getProperty("Prop1") == "1");
test(pa->getProperty("Bogus") == "");
//
// Test: PropertiesAdmin::getProperties()
//
Ice::PropertyDict pd = pa->getPropertiesForPrefix("");
test(pd.size() == 5);
test(pd["Prop1"] == "1");
test(pd["Prop2"] == "2");
test(pd["Prop3"] == "3");
test(pd["Ice.Config"] == "config.service");
test(pd["Ice.ProgramName"] == "IceBox-TestService");
Ice::PropertyDict changes;
//
// Test: PropertiesAdmin::setProperties()
//
Ice::PropertyDict setProps;
setProps["Prop1"] = "10"; // Changed
setProps["Prop2"] = "20"; // Changed
setProps["Prop3"] = ""; // Removed
setProps["Prop4"] = "4"; // Added
setProps["Prop5"] = "5"; // Added
pa->setProperties(setProps);
test(pa->getProperty("Prop1") == "10");
test(pa->getProperty("Prop2") == "20");
test(pa->getProperty("Prop3") == "");
test(pa->getProperty("Prop4") == "4");
test(pa->getProperty("Prop5") == "5");
changes = facet->getChanges();
test(changes.size() == 5);
test(changes["Prop1"] == "10");
test(changes["Prop2"] == "20");
test(changes["Prop3"] == "");
test(changes["Prop4"] == "4");
test(changes["Prop5"] == "5");
pa->setProperties(setProps);
changes = facet->getChanges();
test(changes.empty());
}
cout << "ok" << endl;
cout << "testing metrics admin facet... " << flush;
{
IceMX::MetricsAdminPrx ma = IceMX::MetricsAdminPrx::checkedCast(admin, "IceBox.Service.TestService.Metrics");
Ice::PropertiesAdminPrx pa =
Ice::PropertiesAdminPrx::checkedCast(admin, "IceBox.Service.TestService.Properties");
Ice::StringSeq views;
Ice::StringSeq disabledViews;
views = ma->getMetricsViewNames(disabledViews);
test(views.empty());
Ice::PropertyDict setProps;
setProps["IceMX.Metrics.Debug.GroupBy"] = "id";
setProps["IceMX.Metrics.All.GroupBy"] = "none";
setProps["IceMX.Metrics.Parent.GroupBy"] = "parent";
pa->setProperties(setProps);
pa->setProperties(Ice::PropertyDict());
views = ma->getMetricsViewNames(disabledViews);
test(views.size() == 3);
// Make sure that the IceBox communicator metrics admin is a separate instance.
test(IceMX::MetricsAdminPrx::checkedCast(admin, "Metrics")->getMetricsViewNames(disabledViews).empty());
}
cout << "ok" << endl;
}
示例5: c
MetricsPrx
allTests(const Ice::CommunicatorPtr& communicator, const CommunicatorObserverIPtr& obsv)
{
MetricsPrx metrics = MetricsPrx::checkedCast(communicator->stringToProxy("metrics:default -p 12010"));
cout << "testing metrics admin facet checkedCast... " << flush;
Ice::ObjectPrx admin = communicator->getAdmin()->ice_collocationOptimized(false);
Ice::PropertiesAdminPrx clientProps = Ice::PropertiesAdminPrx::checkedCast(admin, "Properties");
IceMX::MetricsAdminPrx clientMetrics = IceMX::MetricsAdminPrx::checkedCast(admin, "Metrics");
test(clientProps && clientMetrics);
admin = metrics->getAdmin();
Ice::PropertiesAdminPrx serverProps = Ice::PropertiesAdminPrx::checkedCast(admin, "Properties");
IceMX::MetricsAdminPrx serverMetrics = IceMX::MetricsAdminPrx::checkedCast(admin, "Metrics");
test(serverProps && serverMetrics);
UpdateCallbackI* update = new UpdateCallbackI(serverProps);
Ice::NativePropertiesAdminPtr::dynamicCast(communicator->findAdminFacet("Properties"))->addUpdateCallback(update);
cout << "ok" << endl;
Ice::PropertyDict props;
cout << "testing group by none..." << flush;
props["IceMX.Metrics.View.GroupBy"] = "none";
updateProps(clientProps, serverProps, update, props);
#ifndef ICE_OS_WINRT
int threadCount = 4;
#else
int threadCount = 3; // No endpoint host resolver thread with WinRT.
#endif
Ice::Long timestamp;
IceMX::MetricsView view = clientMetrics->getMetricsView("View", timestamp);
test(view["Connection"].size() == 1 && view["Connection"][0]->current == 1 && view["Connection"][0]->total == 1);
test(view["Thread"].size() == 1 && view["Thread"][0]->current == threadCount &&
view["Thread"][0]->total == threadCount);
cout << "ok" << endl;
cout << "testing group by id..." << flush;
props["IceMX.Metrics.View.GroupBy"] = "id";
updateProps(clientProps, serverProps, update, props);
metrics->ice_ping();
metrics->ice_ping();
metrics->ice_connectionId("Con1")->ice_ping();
metrics->ice_connectionId("Con1")->ice_ping();
metrics->ice_connectionId("Con1")->ice_ping();
view = clientMetrics->getMetricsView("View", timestamp);
test(static_cast<int>(view["Thread"].size()) == threadCount);
test(view["Connection"].size() == 2);
test(view["Invocation"].size() == 1);
IceMX::InvocationMetricsPtr invoke = IceMX::InvocationMetricsPtr::dynamicCast(view["Invocation"][0]);
test(invoke->id.find("[ice_ping]") > 0 && invoke->current == 0 && invoke->total == 5);
test(invoke->remotes.size() == 2);
test(invoke->remotes[0]->total = 2);
test(invoke->remotes[1]->total = 3);
view = serverMetrics->getMetricsView("View", timestamp);
test(view["Thread"].size() > 4);
test(view["Connection"].size() == 2);
test(view["Dispatch"].size() == 1);
test(view["Dispatch"][0]->current <= 1 && view["Dispatch"][0]->total == 5);
test(view["Dispatch"][0]->id.find("[ice_ping]") > 0);
metrics->ice_getConnection()->close(false);
metrics->ice_connectionId("Con1")->ice_getConnection()->close(false);
waitForCurrent(clientMetrics, "View", "Connection", 0);
waitForCurrent(serverMetrics, "View", "Connection", 0);
clearView(clientProps, serverProps, update);
cout << "ok" << endl;
cout << "testing connection metrics... " << flush;
props["IceMX.Metrics.View.Map.Connection.GroupBy"] = "none";
updateProps(clientProps, serverProps, update, props, "Connection");
test(clientMetrics->getMetricsView("View", timestamp)["Connection"].empty());
test(serverMetrics->getMetricsView("View", timestamp)["Connection"].empty());
metrics->ice_ping();
IceMX::ConnectionMetricsPtr cm1, sm1, cm2, sm2;
cm1 = IceMX::ConnectionMetricsPtr::dynamicCast(clientMetrics->getMetricsView("View", timestamp)["Connection"][0]);
sm1 = IceMX::ConnectionMetricsPtr::dynamicCast(serverMetrics->getMetricsView("View", timestamp)["Connection"][0]);
sm1 = getServerConnectionMetrics(serverMetrics, 25);
test(cm1->total == 1 && sm1->total == 1);
metrics->ice_ping();
cm2 = IceMX::ConnectionMetricsPtr::dynamicCast(clientMetrics->getMetricsView("View", timestamp)["Connection"][0]);
//.........这里部分代码省略.........
示例6: readDirectory
bool
NodeI::canRemoveServerDirectory(const string& name)
{
//
// Check if there's files which we didn't create.
//
Ice::StringSeq c = readDirectory(_serversDir + "/" + name);
set<string> contents(c.begin(), c.end());
contents.erase("dbs");
contents.erase("config");
contents.erase("distrib");
contents.erase("revision");
contents.erase("data");
Ice::StringSeq serviceDataDirs;
for(set<string>::const_iterator p = contents.begin(); p != contents.end(); ++p)
{
if(p->find("data_") != 0)
{
return false;
}
serviceDataDirs.push_back(*p);
}
if(!contents.empty())
{
return false;
}
c = readDirectory(_serversDir + "/" + name + "/config");
for(Ice::StringSeq::const_iterator p = c.begin() ; p != c.end(); ++p)
{
if(p->find("config") != 0)
{
return false;
}
}
if(IceUtilInternal::directoryExists(_serversDir + "/" + name + "/dbs"))
{
c = readDirectory(_serversDir + "/" + name + "/dbs");
for(Ice::StringSeq::const_iterator p = c.begin() ; p != c.end(); ++p)
{
try
{
Ice::StringSeq files = readDirectory(_serversDir + "/" + name + "/dbs/" + *p);
files.erase(remove(files.begin(), files.end(), "DB_CONFIG"), files.end());
files.erase(remove(files.begin(), files.end(), "__Freeze"), files.end());
if(!files.empty())
{
return false;
}
}
catch(const string&)
{
return false;
}
}
}
if(IceUtilInternal::directoryExists(_serversDir + "/" + name + "/data"))
{
if(!readDirectory(_serversDir + "/" + name + "/data").empty())
{
return false;
}
}
for(Ice::StringSeq::const_iterator p = serviceDataDirs.begin(); p != serviceDataDirs.end(); ++p)
{
try
{
if(!readDirectory(_serversDir + "/" + name + "/" + *p).empty())
{
return false;
}
}
catch(const string&)
{
return false;
}
}
return true;
}
示例7: os
void
logTests(const Ice::CommunicatorPtr& comm, const AdminSessionPrx& session)
{
cout << "testing stderr/stdout/log files... " << flush;
string testDir = comm->getProperties()->getProperty("TestDir");
assert(!testDir.empty());
try
{
session->openServerStdErr("LogServer", -1);
test(false);
}
catch(const FileNotAvailableException&)
{
}
try
{
session->openServerStdOut("LogServer", -1);
test(false);
}
catch(const FileNotAvailableException&)
{
}
try
{
session->openServerLog("LogServer", "unknown.txt", -1);
test(false);
}
catch(const FileNotAvailableException&)
{
}
Ice::ObjectPrx obj = TestIntfPrx::checkedCast(comm->stringToProxy("LogServer"));
try
{
session->openServerStdErr("LogServer", -1)->destroy();
session->openServerStdOut("LogServer", -1)->destroy();
}
catch(const FileNotAvailableException& ex)
{
cerr << ex.reason << endl;
test(false);
}
FileIteratorPrx it;
Ice::StringSeq lines;
try
{
//
// Test with empty file.
//
string path = testDir + "/log1.txt";
ofstream os(path.c_str());
os.close();
it = session->openServerLog("LogServer", testDir + "/log1.txt", -1);
test(it->read(1024, lines) && lines.empty());
test(it->read(1024, lines) && lines.empty());
it->destroy();
it = session->openServerLog("LogServer", testDir + "/log1.txt", 0);
test(it->read(1024, lines) && lines.empty());
test(it->read(1024, lines) && lines.empty());
it->destroy();
it = session->openServerLog("LogServer", testDir + "/log1.txt", 100);
test(it->read(1024, lines) && lines.empty());
test(it->read(1024, lines) && lines.empty());
it->destroy();
}
catch(const FileNotAvailableException& ex)
{
cerr << ex.reason << endl;
test(false);
}
try
{
//
// Test with log file with one line with no EOL on last line.
//
string path = testDir + "/log2.txt";
ofstream os(path.c_str());
os << "one line file with no EOL on last line";
os.close();
it = session->openServerLog("LogServer", testDir + "/log2.txt", -1);
test(it->read(1024, lines) && lines.size() == 1);
test(lines[0] == "one line file with no EOL on last line");
test(it->read(1024, lines) && lines.empty());
it->destroy();
it = session->openServerLog("LogServer", testDir + "/log2.txt", 0);
test(it->read(1024, lines) && lines.empty());
test(it->read(1024, lines) && lines.empty());
it->destroy();
it = session->openServerLog("LogServer", testDir + "/log2.txt", 1);
test(it->read(1024, lines) && lines.size() == 1);
test(lines[0] == "one line file with no EOL on last line");
test(it->read(1024, lines) && lines.empty());
//.........这里部分代码省略.........