2 // Copyright (c) 2020 Fraunhofer Institute for Applied Information Technology (FIT)
3 // Network Research Group (NET)
4 // Schloss Birlinghoven, 53754 Sankt Augustin, GERMANY
5 // Contact: support@wiback.org
7 // This file is part of the SENF code tree.
8 // It is licensed under the 3-clause BSD License (aka New BSD License).
9 // See LICENSE.txt in the top level directory for details or visit
10 // https://opensource.org/licenses/BSD-3-Clause
15 \brief Server inline non-template implementation */
17 //#include "Server.ih"
21 #define prefix_ inline
22 //-/////////////////////////////////////////////////////////////////////////////////////////////////
24 //-/////////////////////////////////////////////////////////////////////////////////////////////////
25 // senf::console::detail::ServerManager
27 prefix_ void senf::console::detail::ServerManager::add(ptr server)
29 instance().servers_.insert(server);
32 prefix_ void senf::console::detail::ServerManager::remove(ptr server)
34 instance().servers_.erase(instance().servers_.find(server));
37 prefix_ senf::console::detail::ServerManager & senf::console::detail::ServerManager::instance()
39 static ServerManager manager;
43 //-/////////////////////////////////////////////////////////////////////////////////////////////////
44 // senf::console::detail::SocketStreamSink
46 prefix_ senf::console::detail::SocketStreamSink::SocketStreamSink(Client & client)
50 prefix_ senf::console::Client & senf::console::detail::SocketStreamSink::client()
56 //-/////////////////////////////////////////////////////////////////////////////////////////////////
57 // senf::console::Server
59 prefix_ senf::console::Server & senf::console::Server::name(std::string const & name)
65 prefix_ std::string const & senf::console::Server::name()
71 prefix_ senf::console::DirectoryNode & senf::console::Server::root()
77 prefix_ senf::console::Server & senf::console::Server::root(DirectoryNode & root)
79 root_ = root.thisptr();
83 prefix_ senf::console::Server & senf::console::Server::mode(Mode m)
89 prefix_ senf::console::Server::Mode senf::console::Server::mode()
95 prefix_ void senf::console::Server::stop()
98 detail::ServerManager::remove(boost::intrusive_ptr<Server>(this));
101 //-/////////////////////////////////////////////////////////////////////////////////////////////////
102 // senf::console::Client
104 prefix_ senf::console::Client::~Client()
106 stream() << std::flush;
109 prefix_ void senf::console::Client::stop()
111 // THIS COMMITS SUICIDE. THE INSTANCE IS GONE AFTER removeClient RETURNS
112 server_.removeClient(*this);
115 prefix_ std::string const & senf::console::Client::name()
121 prefix_ std::string senf::console::Client::promptString()
124 return name_ + ":" + executor_.cwdPath() + "$";
127 prefix_ senf::console::DirectoryNode & senf::console::Client::root()
130 return server_.root();
133 prefix_ senf::console::DirectoryNode & senf::console::Client::cwd()
136 return executor_.cwd();
139 prefix_ senf::console::Server::Mode senf::console::Client::mode()
145 prefix_ void senf::console::Client::write(std::string const & data)
148 reader_->write(data);
151 prefix_ std::string const & senf::console::Client::backtrace()
157 prefix_ unsigned senf::console::Client::width()
160 return reader_->width();
163 prefix_ senf::console::Client & senf::console::Client::get(std::ostream & os)
165 return dynamic_cast<detail::SocketStreamOStream&>(os)->client();
168 prefix_ senf::console::Client::ClientHandle senf::console::Client::handle()
174 prefix_ std::ostream & senf::console::Client::stream()
176 return out_t::member;
179 //-/////////////////////////////////////////////////////////////////////////////////////////////////
180 // senf::console::detail::ClientReader
182 prefix_ senf::console::detail::ClientReader::~ClientReader()
185 prefix_ senf::console::Client & senf::console::detail::ClientReader::client()
191 prefix_ std::string senf::console::detail::ClientReader::promptString()
194 return client().promptString();
197 prefix_ senf::console::detail::ClientReader::ClientHandle senf::console::detail::ClientReader::handle()
200 return client().handle();
203 prefix_ std::ostream & senf::console::detail::ClientReader::stream()
206 return client().stream();
209 prefix_ void senf::console::detail::ClientReader::stopClient()
214 prefix_ std::string::size_type
215 senf::console::detail::ClientReader::handleInput(std::string const & input, bool incremental)
218 return client().handleInput(input, incremental);
221 prefix_ void senf::console::detail::ClientReader::disablePrompt()
226 prefix_ void senf::console::detail::ClientReader::enablePrompt()
231 prefix_ void senf::console::detail::ClientReader::write(std::string const & data)
236 prefix_ unsigned senf::console::detail::ClientReader::width()
242 prefix_ senf::console::detail::ClientReader::ClientReader(Client & client)
246 //-/////////////////////////////////////////////////////////////////////////////////////////////////
253 // comment-column: 40
254 // c-file-style: "senf"
255 // indent-tabs-mode: nil
256 // ispell-local-dictionary: "american"
257 // compile-command: "scons -u test"