diff options
author | Benoit Foucher <benoit@zeroc.com> | 2014-11-03 15:58:54 +0100 |
---|---|---|
committer | Benoit Foucher <benoit@zeroc.com> | 2014-11-03 15:58:54 +0100 |
commit | 581d0449b2c5f1bbfd5bb3d6d1216040b832b273 (patch) | |
tree | c3ebc0b05f1ad8d5dc2156e471c799b30be8ecde /cpp/demo/manual/simple_filesystem/FilesystemI.cpp | |
parent | Fixed ICE-5816: Silverlight build failure (diff) | |
download | ice-581d0449b2c5f1bbfd5bb3d6d1216040b832b273.tar.bz2 ice-581d0449b2c5f1bbfd5bb3d6d1216040b832b273.tar.xz ice-581d0449b2c5f1bbfd5bb3d6d1216040b832b273.zip |
Fixed ICE-5811: renamed book demos to manual demos
Diffstat (limited to 'cpp/demo/manual/simple_filesystem/FilesystemI.cpp')
-rw-r--r-- | cpp/demo/manual/simple_filesystem/FilesystemI.cpp | 97 |
1 files changed, 97 insertions, 0 deletions
diff --git a/cpp/demo/manual/simple_filesystem/FilesystemI.cpp b/cpp/demo/manual/simple_filesystem/FilesystemI.cpp new file mode 100644 index 00000000000..75cefb39023 --- /dev/null +++ b/cpp/demo/manual/simple_filesystem/FilesystemI.cpp @@ -0,0 +1,97 @@ +// ********************************************************************** +// +// Copyright (c) 2003-2014 ZeroC, Inc. All rights reserved. +// +// This copy of Ice is licensed to you under the terms described in the +// ICE_LICENSE file included in this distribution. +// +// ********************************************************************** + +#include <IceUtil/IceUtil.h> +#include <FilesystemI.h> + +using namespace std; + +// Slice Node::name() operation + +std::string +Filesystem::NodeI::name(const Ice::Current&) +{ + return _name; +} + +// NodeI constructor + +Filesystem::NodeI::NodeI(const Ice::CommunicatorPtr&, const string& name, const DirectoryIPtr& parent) : + _name(name), _parent(parent) +{ + // Create an identity. The root directory has the fixed identity "RootDir" + if(parent) + { + _id.name = IceUtil::generateUUID(); + } + else + { + _id.name = "RootDir"; + } +} + +// NodeI activate() member function + +void +Filesystem::NodeI::activate(const Ice::ObjectAdapterPtr& a) +{ + NodePrx thisNode = NodePrx::uncheckedCast(a->add(this, _id)); + if(_parent) + { + _parent->addChild(thisNode); + } +} + +// Slice File::read() operation + +Filesystem::Lines +Filesystem::FileI::read(const Ice::Current&) +{ + return _lines; +} + +// Slice File::write() operation + +void +Filesystem::FileI::write(const Filesystem::Lines& text, const Ice::Current&) +{ + _lines = text; +} + +// FileI constructor + +Filesystem::FileI::FileI(const Ice::CommunicatorPtr& communicator, const string& name, const DirectoryIPtr& parent) : + NodeI(communicator, name, parent) +{ +} + +// Slice Directory::list() operation + +Filesystem::NodeSeq +Filesystem::DirectoryI::list(const Ice::Current&) +{ + return _contents; +} + +// DirectoryI constructor + +Filesystem::DirectoryI::DirectoryI(const Ice::CommunicatorPtr& communicator, const string& name, + const DirectoryIPtr& parent) : + NodeI(communicator, name, parent) +{ +} + +// addChild is called by the child in order to add +// itself to the _contents member of the parent + +void +Filesystem::DirectoryI::addChild(const NodePrx& child) +{ + _contents.push_back(child); +} |