本文整理汇总了C++中DirectoryPrx类的典型用法代码示例。如果您正苦于以下问题:C++ DirectoryPrx类的具体用法?C++ DirectoryPrx怎么用?C++ DirectoryPrx使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了DirectoryPrx类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: catch
void
Parser::write(std::list<string>& args)
{
DirectoryPrx dir = _dirs.front();
string name = args.front();
args.pop_front();
NodeDesc d;
try
{
d = dir->find(name);
}
catch(const NoSuchName&)
{
cout << "`" << name << "': no such file" << endl;
return;
}
if(d.type == DirType)
{
cout << "`" << name << "': not a file" << endl;
return;
}
FilePrx f = FilePrx::uncheckedCast(d.proxy);
Lines l;
for(std::list<string>::const_iterator i = args.begin(); i != args.end(); ++i)
{
l.push_back(*i);
}
f->write(l);
}
示例2: listRecursive
static void
listRecursive(const DirectoryPrx& dir, int depth = 0)
{
string indent(++depth, '\t');
NodeSeq contents = dir->list();
for(NodeSeq::const_iterator i = contents.begin(); i != contents.end(); ++i)
{
DirectoryPrx dir = DirectoryPrx::checkedCast(*i);
FilePrx file = FilePrx::uncheckedCast(*i);
cout << indent << (*i)->name() << (dir ? " (directory):" : " (file):") << endl;
if(dir)
{
listRecursive(dir, depth);
}
else
{
Lines text = file->read();
for(Lines::const_iterator j = text.begin(); j != text.end(); ++j)
{
cout << indent << "\t" << *j << endl;
}
}
}
}
示例3: while
void
Parser::cd(const string& name)
{
if(name == "/")
{
while(_dirs.size() > 1)
{
_dirs.pop_front();
}
return;
}
if(name == "..")
{
if(_dirs.size() > 1)
{
_dirs.pop_front();
}
return;
}
DirectoryPrx dir = _dirs.front();
NodeDesc d;
try
{
d = dir->find(name);
}
catch(const NoSuchName&)
{
cout << "`" << name << "': no such directory" << endl;
return;
}
if(d.type == FileType)
{
cout << "`" << name << "': not a directory" << endl;
return;
}
_dirs.push_front(DirectoryPrx::uncheckedCast(d.proxy));
}
示例4: indent
void
Parser::list(const DirectoryPrx& dir, bool recursive, int depth)
{
string indent(depth++, '\t');
NodeDescSeq contents = dir->list();
for(NodeDescSeq::const_iterator i = contents.begin(); i != contents.end(); ++i)
{
DirectoryPrx d = i->type == DirType ? DirectoryPrx::uncheckedCast(i->proxy) : (DirectoryPrx)0;
cout << indent << i->name << (d ? " (directory)" : " (file)");
if(d && recursive)
{
cout << ":" << endl;
list(d, true, depth);
}
else
{
cout << endl;
}
}
}
示例5: if
void AghPhoneDialog::menuTriggered(QAction *action) {
cout << action->text().toLocal8Bit().data() << endl;
QString operation = action->text();
if (operation == "Preferences") {
prefDialog->exec();
prefDialog->updateConfiguration();
configuration->saveConf();
} else if (operation == "Close") {
terminateApplication();
} else if (operation == "Search in directory") {
searchDir->exec();
TerminalAddress *foundTerminal = searchDir->getSelectedTerminal();
// check whether terminal was selected
if (foundTerminal == NULL) {
return;
}
QString foundTermName = foundTerminal->name.c_str();
foundTermName += ":";
foundTermName += foundTerminal->port.c_str();
if (foundTerminal != 0) {
this->putTerminalIntoList(foundTerminal, foundTermName);
}
} else if (operation == "Log in") {
registeredAddress = new TerminalAddress;
if (isRegistered) {
QMessageBox::critical( this, this->windowTitle(),
"User already registered");
return;
}
if (this->configuration->directoryAlias->size() <= 0) {
QMessageBox::critical( this, this->windowTitle(),
"User alias not specified! Check your configuration.");
return;
}
if (this->configuration->localPort->size() <= 0) {
QMessageBox::critical( this, this->windowTitle(),
"Local port not specified! Check your configuration.");
return;
}
registeredAddress->name = *(this->configuration->directoryAlias);
registeredAddress->port = *(this->configuration->localPort);
// Get directory reference
QString errorMessage = this->configuration->validateDirectory().c_str();
if (errorMessage.count() > 0) {
QMessageBox::critical( this, this->windowTitle(),
errorMessage);
} else {
// search for directory
try {
Ice::CommunicatorPtr ic = Ice::initialize();
stringstream a;
a << *(configuration->directoryName)
<< ":default -h " << *(configuration->directoryAddress)
<< " -p " << *(configuration->directoryPort);
Ice::ObjectPrx base = ic->stringToProxy ( a.str() );
DirectoryPrx directory = DirectoryPrx::checkedCast ( base );
if ( !directory ) {
QMessageBox::critical( this, this->windowTitle(),
"Connection to directory failed, please check your configuration!");
} else {
directory->registerTerminal(*registeredAddress);
isRegistered = true;
QString message("Terminal ");
message += registeredAddress->name.c_str();
message += " successfully registered.";
statusbar->showMessage(message, 5000);
}
ic->destroy();
} catch (TerminalExistsException ex) {
QMessageBox::critical( this, this->windowTitle(),
"User already registered, change your alias!");
return;
} catch (...) {
QMessageBox::critical( this, this->windowTitle(),
"Connection to directory failed, please check your configuration!");
return;
}
}
} else if (operation == "Log out") {
if (!isRegistered) {
QMessageBox::critical( this, this->windowTitle(),
"User not registered");
return;
//.........这里部分代码省略.........
示例6: main
int main(int argc, char **argv) {
int lIcePort;
int lRtpPort;
int rDirPort;
string rDirAddr;
string alias;
DirectoryPrx directory;
if (argc < 6) {
cout << "bad usage:\n\n";
cout << "\t\tprogram lIcePort lRtpPort rDirPort rDirAddr alias\n\n";
return 0;
}
/* arguments */
lIcePort = atoi(argv[1]);
lRtpPort = atoi(argv[2]);
rDirPort = atoi(argv[3]);
rDirAddr.append(argv[4]);
alias.append(argv[5]);
try {
/* locate directory */
Ice::CommunicatorPtr ic = Ice::initialize ();
stringstream a;
a << string("Directory") << ":default -h " << rDirAddr << " -p " << rDirPort;
Ice::ObjectPrx base = ic->stringToProxy ( a.str() );
directory = DirectoryPrx::checkedCast ( base );
if ( !directory )
throw "Invalid proxy";
/* log in */
TerminalAddress address;
address.name = alias;
std::ostringstream o2;
o2 << string("") << lIcePort;
address.port = o2.str();
address.type = MCUTERMINAL;
try {
directory->registerTerminal(address);
} catch(BadLoginException e) {
cerr << "Bad login\n";
} catch(TerminalExistsException e) {
cerr << "Terminal already exists\n";
}
} catch(...) {
clog << "Directory lookup error" << endl;
}
try {
// Set up a simple configuration that logs on the console.
BasicConfigurator::configure();
} catch(log4cxx::helpers::Exception& e) {
clog << "severe error" << endl;
}
Mixer m(lIcePort);
m.setLocalRtpPort(lRtpPort);
}