4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
6 // The contents of this file are subject to the Fraunhofer FOKUS Public License
7 // Version 1.0 (the "License"); you may not use this file except in compliance
8 // with the License. You may obtain a copy of the License at
9 // http://senf.berlios.de/license.html
11 // The Fraunhofer FOKUS Public License Version 1.0 is based on,
12 // but modifies the Mozilla Public License Version 1.1.
13 // See the full license text for the amendments.
15 // Software distributed under the License is distributed on an "AS IS" basis,
16 // WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
17 // for the specific language governing rights and limitations under the License.
19 // The Original Code is Fraunhofer FOKUS code.
21 // The Initial Developer of the Original Code is Fraunhofer-Gesellschaft e.V.
22 // (registered association), Hansastraße 27 c, 80686 Munich, Germany.
23 // All Rights Reserved.
26 // Stefan Bund <g0dil@berlios.de>
29 \brief Server inline non-template implementation */
31 //#include "Server.ih"
35 #define prefix_ inline
36 //-/////////////////////////////////////////////////////////////////////////////////////////////////
38 //-/////////////////////////////////////////////////////////////////////////////////////////////////
39 // senf::console::detail::ServerManager
41 prefix_ void senf::console::detail::ServerManager::add(ptr server)
43 instance().servers_.insert(server);
46 prefix_ void senf::console::detail::ServerManager::remove(ptr server)
48 instance().servers_.erase(instance().servers_.find(server));
51 prefix_ senf::console::detail::ServerManager & senf::console::detail::ServerManager::instance()
53 static ServerManager manager;
57 //-/////////////////////////////////////////////////////////////////////////////////////////////////
58 // senf::console::detail::SocketStreamSink
60 prefix_ senf::console::detail::SocketStreamSink::SocketStreamSink(Client & client)
64 prefix_ senf::console::Client & senf::console::detail::SocketStreamSink::client()
70 //-/////////////////////////////////////////////////////////////////////////////////////////////////
71 // senf::console::Server
73 prefix_ senf::console::Server & senf::console::Server::name(std::string const & name)
79 prefix_ std::string const & senf::console::Server::name()
85 prefix_ senf::console::DirectoryNode & senf::console::Server::root()
91 prefix_ senf::console::Server & senf::console::Server::root(DirectoryNode & root)
93 root_ = root.thisptr();
97 prefix_ senf::console::Server & senf::console::Server::mode(Mode m)
103 prefix_ senf::console::Server::Mode senf::console::Server::mode()
109 prefix_ void senf::console::Server::stop()
112 detail::ServerManager::remove(boost::intrusive_ptr<Server>(this));
115 //-/////////////////////////////////////////////////////////////////////////////////////////////////
116 // senf::console::Client
118 prefix_ senf::console::Client::~Client()
120 stream() << std::flush;
123 prefix_ void senf::console::Client::stop()
125 // THIS COMMITS SUICIDE. THE INSTANCE IS GONE AFTER removeClient RETURNS
126 server_.removeClient(*this);
129 prefix_ std::string const & senf::console::Client::name()
135 prefix_ std::string senf::console::Client::promptString()
138 return name_ + ":" + executor_.cwdPath() + "$";
141 prefix_ senf::console::DirectoryNode & senf::console::Client::root()
144 return server_.root();
147 prefix_ senf::console::DirectoryNode & senf::console::Client::cwd()
150 return executor_.cwd();
153 prefix_ senf::console::Server::Mode senf::console::Client::mode()
159 prefix_ void senf::console::Client::write(std::string const & data)
162 reader_->write(data);
165 prefix_ std::string const & senf::console::Client::backtrace()
171 prefix_ unsigned senf::console::Client::width()
174 return reader_->width();
177 prefix_ senf::console::Client & senf::console::Client::get(std::ostream & os)
179 return dynamic_cast<detail::SocketStreamOStream&>(os)->client();
182 prefix_ senf::console::Client::ClientHandle senf::console::Client::handle()
188 prefix_ std::ostream & senf::console::Client::stream()
190 return out_t::member;
193 //-/////////////////////////////////////////////////////////////////////////////////////////////////
194 // senf::console::detail::ClientReader
196 prefix_ senf::console::detail::ClientReader::~ClientReader()
199 prefix_ senf::console::Client & senf::console::detail::ClientReader::client()
205 prefix_ std::string senf::console::detail::ClientReader::promptString()
208 return client().promptString();
211 prefix_ senf::console::detail::ClientReader::ClientHandle senf::console::detail::ClientReader::handle()
214 return client().handle();
217 prefix_ std::ostream & senf::console::detail::ClientReader::stream()
220 return client().stream();
223 prefix_ void senf::console::detail::ClientReader::stopClient()
228 prefix_ std::string::size_type
229 senf::console::detail::ClientReader::handleInput(std::string const & input, bool incremental)
232 return client().handleInput(input, incremental);
235 prefix_ void senf::console::detail::ClientReader::disablePrompt()
240 prefix_ void senf::console::detail::ClientReader::enablePrompt()
245 prefix_ void senf::console::detail::ClientReader::write(std::string const & data)
250 prefix_ unsigned senf::console::detail::ClientReader::width()
256 prefix_ senf::console::detail::ClientReader::ClientReader(Client & client)
260 //-/////////////////////////////////////////////////////////////////////////////////////////////////
267 // comment-column: 40
268 // c-file-style: "senf"
269 // indent-tabs-mode: nil
270 // ispell-local-dictionary: "american"
271 // compile-command: "scons -u test"