diff options
Diffstat (limited to 'cpp/demo/book/simple_filesystem')
-rwxr-xr-x | cpp/demo/book/simple_filesystem/Client.cpp | 64 | ||||
-rwxr-xr-x | cpp/demo/book/simple_filesystem/Filesystem.ice | 10 | ||||
-rwxr-xr-x | cpp/demo/book/simple_filesystem/FilesystemI.cpp | 10 | ||||
-rwxr-xr-x | cpp/demo/book/simple_filesystem/FilesystemI.h | 30 | ||||
-rwxr-xr-x | cpp/demo/book/simple_filesystem/Server.cpp | 80 |
5 files changed, 97 insertions, 97 deletions
diff --git a/cpp/demo/book/simple_filesystem/Client.cpp b/cpp/demo/book/simple_filesystem/Client.cpp index 870b879e0d9..00cbc8a425e 100755 --- a/cpp/demo/book/simple_filesystem/Client.cpp +++ b/cpp/demo/book/simple_filesystem/Client.cpp @@ -27,16 +27,16 @@ listRecursive(const DirectoryPrx & dir, int depth = 0) 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; - } + 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; + } } } @@ -46,38 +46,38 @@ main(int argc, char * argv[]) int status = 0; Ice::CommunicatorPtr ic; try { - // Create a communicator - // - ic = Ice::initialize(argc, argv); + // Create a communicator + // + ic = Ice::initialize(argc, argv); - // Create a proxy for the root directory - // - Ice::ObjectPrx base = ic->stringToProxy("RootDir:default -p 10000"); - if (!base) - throw "Could not create proxy"; + // Create a proxy for the root directory + // + Ice::ObjectPrx base = ic->stringToProxy("RootDir:default -p 10000"); + if (!base) + throw "Could not create proxy"; - // Down-cast the proxy to a Directory proxy - // - DirectoryPrx rootDir = DirectoryPrx::checkedCast(base); - if (!rootDir) - throw "Invalid proxy"; + // Down-cast the proxy to a Directory proxy + // + DirectoryPrx rootDir = DirectoryPrx::checkedCast(base); + if (!rootDir) + throw "Invalid proxy"; - // Recursively list the contents of the root directory - // - cout << "Contents of root directory:" << endl; - listRecursive(rootDir); + // Recursively list the contents of the root directory + // + cout << "Contents of root directory:" << endl; + listRecursive(rootDir); } catch (const Ice::Exception & ex) { - cerr << ex << endl; - status = 1; + cerr << ex << endl; + status = 1; } catch (const char * msg) { - cerr << msg << endl; - status = 1; + cerr << msg << endl; + status = 1; } // Clean up // if (ic) - ic->destroy(); + ic->destroy(); return status; } diff --git a/cpp/demo/book/simple_filesystem/Filesystem.ice b/cpp/demo/book/simple_filesystem/Filesystem.ice index 8592c68381e..de701e15cee 100755 --- a/cpp/demo/book/simple_filesystem/Filesystem.ice +++ b/cpp/demo/book/simple_filesystem/Filesystem.ice @@ -9,23 +9,23 @@ module Filesystem { exception GenericError { - string reason; + string reason; }; interface Node { - ["cpp:const"] idempotent string name(); + ["cpp:const"] idempotent string name(); }; sequence<string> Lines; interface File extends Node { - ["cpp:const"] idempotent Lines read(); - idempotent void write(Lines text) throws GenericError; + ["cpp:const"] idempotent Lines read(); + idempotent void write(Lines text) throws GenericError; }; sequence<Node*> NodeSeq; interface Directory extends Node { - ["cpp:const"] idempotent NodeSeq list(); + ["cpp:const"] idempotent NodeSeq list(); }; }; diff --git a/cpp/demo/book/simple_filesystem/FilesystemI.cpp b/cpp/demo/book/simple_filesystem/FilesystemI.cpp index 8560075d36c..7367e89e3e8 100755 --- a/cpp/demo/book/simple_filesystem/FilesystemI.cpp +++ b/cpp/demo/book/simple_filesystem/FilesystemI.cpp @@ -12,7 +12,7 @@ using namespace std; -Ice::ObjectAdapterPtr Filesystem::NodeI::_adapter; // static member +Ice::ObjectAdapterPtr Filesystem::NodeI::_adapter; // static member // Slice Node::name() operation @@ -39,15 +39,15 @@ Filesystem::NodeI::NodeI(const Ice::CommunicatorPtr & ic, const string & name, c // Ice::Identity myID; if (parent) - myID = ic->stringToIdentity(IceUtil::generateUUID()); + myID = ic->stringToIdentity(IceUtil::generateUUID()); else - myID = ic->stringToIdentity("RootDir"); + myID = ic->stringToIdentity("RootDir"); // Create a proxy for the new node and add it as a child to the parent // NodePrx thisNode = NodePrx::uncheckedCast(_adapter->createProxy(myID)); if (parent) - parent->addChild(thisNode); + parent->addChild(thisNode); // Activate the servant // @@ -66,7 +66,7 @@ Filesystem::FileI::read(const Ice::Current &) const void Filesystem::FileI::write(const Filesystem::Lines & text, - const Ice::Current &) + const Ice::Current &) { _lines = text; } diff --git a/cpp/demo/book/simple_filesystem/FilesystemI.h b/cpp/demo/book/simple_filesystem/FilesystemI.h index fde910b3ac0..c627ce35116 100755 --- a/cpp/demo/book/simple_filesystem/FilesystemI.h +++ b/cpp/demo/book/simple_filesystem/FilesystemI.h @@ -19,33 +19,33 @@ namespace Filesystem { class NodeI : virtual public Node { public: - virtual std::string name(const Ice::Current &) const; - NodeI(const Ice::CommunicatorPtr &, const std::string &, const DirectoryIPtr & parent); - static Ice::ObjectAdapterPtr _adapter; + virtual std::string name(const Ice::Current &) const; + NodeI(const Ice::CommunicatorPtr &, const std::string &, const DirectoryIPtr & parent); + static Ice::ObjectAdapterPtr _adapter; private: - const std::string _name; - DirectoryIPtr _parent; + const std::string _name; + DirectoryIPtr _parent; }; class FileI : virtual public File, - virtual public NodeI { + virtual public NodeI { public: - virtual Lines read(const Ice::Current &) const; - virtual void write(const Lines &, - const Ice::Current &); - FileI(const Ice::CommunicatorPtr &, const std::string &, const DirectoryIPtr &); + virtual Lines read(const Ice::Current &) const; + virtual void write(const Lines &, + const Ice::Current &); + FileI(const Ice::CommunicatorPtr &, const std::string &, const DirectoryIPtr &); private: - Lines _lines; + Lines _lines; }; class DirectoryI : virtual public Directory, - virtual public NodeI { + virtual public NodeI { public: - virtual NodeSeq list(const Ice::Current &) const; + virtual NodeSeq list(const Ice::Current &) const; DirectoryI(const Ice::CommunicatorPtr &, const std::string &, const DirectoryIPtr &); - void addChild(NodePrx child); + void addChild(NodePrx child); private: - NodeSeq _contents; + NodeSeq _contents; }; } diff --git a/cpp/demo/book/simple_filesystem/Server.cpp b/cpp/demo/book/simple_filesystem/Server.cpp index 84cd4fadbdd..59aa1f61e83 100755 --- a/cpp/demo/book/simple_filesystem/Server.cpp +++ b/cpp/demo/book/simple_filesystem/Server.cpp @@ -17,57 +17,57 @@ class FilesystemApp : virtual public Ice::Application { public: virtual int run(int, char * []) { // Terminate cleanly on receipt of a signal - // - shutdownOnInterrupt(); + // + shutdownOnInterrupt(); - // Create an object adapter (stored in the NodeI::_adapter - // static member) - // - NodeI::_adapter = - communicator()->createObjectAdapterWithEndpoints( - "SimpleFilesystem", "default -p 10000"); + // Create an object adapter (stored in the NodeI::_adapter + // static member) + // + NodeI::_adapter = + communicator()->createObjectAdapterWithEndpoints( + "SimpleFilesystem", "default -p 10000"); - // Create the root directory (with name "/" and no parent) - // - DirectoryIPtr root = new DirectoryI(communicator(), "/", 0); + // Create the root directory (with name "/" and no parent) + // + DirectoryIPtr root = new DirectoryI(communicator(), "/", 0); - // Create a file called "README" in the root directory - // - FilePtr file = new FileI(communicator(), "README", root); - Lines text; - text.push_back("This file system contains a collection of poetry."); - file->write(text); + // Create a file called "README" in the root directory + // + FilePtr file = new FileI(communicator(), "README", root); + Lines text; + text.push_back("This file system contains a collection of poetry."); + file->write(text); - // Create a directory called "Coleridge" in the root directory - // - DirectoryIPtr coleridge = new DirectoryI(communicator(), "Coleridge", root); + // Create a directory called "Coleridge" in the root directory + // + DirectoryIPtr coleridge = new DirectoryI(communicator(), "Coleridge", root); - // Create a file called "Kubla_Khan" in the Coleridge directory - // - file = new FileI(communicator(), "Kubla_Khan", coleridge); - text.erase(text.begin(), text.end()); - text.push_back("In Xanadu did Kubla Khan"); - text.push_back("A stately pleasure-dome decree:"); - text.push_back("Where Alph, the sacred river, ran"); - text.push_back("Through caverns measureless to man"); - text.push_back("Down to a sunless sea."); - file->write(text); + // Create a file called "Kubla_Khan" in the Coleridge directory + // + file = new FileI(communicator(), "Kubla_Khan", coleridge); + text.erase(text.begin(), text.end()); + text.push_back("In Xanadu did Kubla Khan"); + text.push_back("A stately pleasure-dome decree:"); + text.push_back("Where Alph, the sacred river, ran"); + text.push_back("Through caverns measureless to man"); + text.push_back("Down to a sunless sea."); + file->write(text); - // All objects are created, allow client requests now - // - NodeI::_adapter->activate(); + // All objects are created, allow client requests now + // + NodeI::_adapter->activate(); - // Wait until we are done - // - communicator()->waitForShutdown(); + // Wait until we are done + // + communicator()->waitForShutdown(); if (interrupted()) { cerr << appName() - << ": received signal, shutting down" << endl; - } + << ": received signal, shutting down" << endl; + } - NodeI::_adapter = 0; + NodeI::_adapter = 0; - return 0; + return 0; }; }; |