// $Id$ // // Copyright (C) 2008 // Fraunhofer Institute for Open Communication Systems (FOKUS) // // The contents of this file are subject to the Fraunhofer FOKUS Public License // Version 1.0 (the "License"); you may not use this file except in compliance // with the License. You may obtain a copy of the License at // http://senf.berlios.de/license.html // // The Fraunhofer FOKUS Public License Version 1.0 is based on, // but modifies the Mozilla Public License Version 1.1. // See the full license text for the amendments. // // Software distributed under the License is distributed on an "AS IS" basis, // WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License // for the specific language governing rights and limitations under the License. // // The Original Code is Fraunhofer FOKUS code. // // The Initial Developer of the Original Code is Fraunhofer-Gesellschaft e.V. // (registered association), Hansastraße 27 c, 80686 Munich, Germany. // All Rights Reserved. // // Contributor(s): // Stefan Bund /** \file \brief Server inline non-template implementation */ //#include "Server.ih" // Custom includes #define prefix_ inline //-///////////////////////////////////////////////////////////////////////////////////////////////// //-///////////////////////////////////////////////////////////////////////////////////////////////// // senf::console::detail::ServerManager prefix_ void senf::console::detail::ServerManager::add(ptr server) { instance().servers_.insert(server); } prefix_ void senf::console::detail::ServerManager::remove(ptr server) { instance().servers_.erase(instance().servers_.find(server)); } prefix_ senf::console::detail::ServerManager & senf::console::detail::ServerManager::instance() { static ServerManager manager; return manager; } //-///////////////////////////////////////////////////////////////////////////////////////////////// // senf::console::detail::NonblockingSocketSink prefix_ senf::console::detail::NonblockingSocketSink::NonblockingSocketSink(Client & client) : client_ (client) {} prefix_ senf::console::Client & senf::console::detail::NonblockingSocketSink::client() const { return client_; } //-///////////////////////////////////////////////////////////////////////////////////////////////// // senf::console::Server prefix_ senf::console::Server & senf::console::Server::name(std::string const & name) { name_ = name; return *this; } prefix_ std::string const & senf::console::Server::name() const { return name_; } prefix_ senf::console::DirectoryNode & senf::console::Server::root() const { return *root_; } prefix_ senf::console::Server & senf::console::Server::root(DirectoryNode & root) { root_ = root.thisptr(); return *this; } prefix_ senf::console::Server & senf::console::Server::mode(Mode m) { mode_ = m; return *this; } prefix_ senf::console::Server::Mode senf::console::Server::mode() const { return mode_; } prefix_ void senf::console::Server::stop() { // commit suicide detail::ServerManager::remove(boost::intrusive_ptr(this)); } //-///////////////////////////////////////////////////////////////////////////////////////////////// // senf::console::Client prefix_ senf::console::Client::~Client() { stream() << std::flush; } prefix_ void senf::console::Client::stop() { // THIS COMMITS SUICIDE. THE INSTANCE IS GONE AFTER removeClient RETURNS server_.removeClient(*this); } prefix_ std::string const & senf::console::Client::name() const { return name_; } prefix_ std::string senf::console::Client::promptString() const { return name_ + ":" + executor_.cwdPath() + "$"; } prefix_ senf::console::DirectoryNode & senf::console::Client::root() const { return server_.root(); } prefix_ senf::console::DirectoryNode & senf::console::Client::cwd() const { return executor_.cwd(); } prefix_ senf::console::Server::Mode senf::console::Client::mode() const { return mode_; } prefix_ void senf::console::Client::write(std::string const & data) const { reader_->write(data); } prefix_ std::string const & senf::console::Client::backtrace() const { return backtrace_; } prefix_ unsigned senf::console::Client::width() const { return reader_->width(); } prefix_ senf::console::Client & senf::console::Client::get(std::ostream & os) { return dynamic_cast(os)->client(); } prefix_ senf::console::Client::ClientHandle senf::console::Client::handle() const { return handle_; } prefix_ std::ostream & senf::console::Client::stream() { return out_t::member; } //-///////////////////////////////////////////////////////////////////////////////////////////////// // senf::console::detail::ClientReader prefix_ senf::console::detail::ClientReader::~ClientReader() {} prefix_ senf::console::Client & senf::console::detail::ClientReader::client() const { return client_; } prefix_ std::string senf::console::detail::ClientReader::promptString() const { return client().promptString(); } prefix_ senf::console::detail::ClientReader::ClientHandle senf::console::detail::ClientReader::handle() const { return client().handle(); } prefix_ std::ostream & senf::console::detail::ClientReader::stream() const { return client().stream(); } prefix_ void senf::console::detail::ClientReader::stopClient() { client().stop(); } prefix_ std::string::size_type senf::console::detail::ClientReader::handleInput(std::string const & input, bool incremental) const { return client().handleInput(input, incremental); } prefix_ void senf::console::detail::ClientReader::disablePrompt() { v_disablePrompt(); } prefix_ void senf::console::detail::ClientReader::enablePrompt() { v_enablePrompt(); } prefix_ void senf::console::detail::ClientReader::write(std::string const & data) { v_write(data); } prefix_ unsigned senf::console::detail::ClientReader::width() const { return v_width(); } prefix_ senf::console::detail::ClientReader::ClientReader(Client & client) : client_ (client) {} //-///////////////////////////////////////////////////////////////////////////////////////////////// #undef prefix_ // Local Variables: // mode: c++ // fill-column: 100 // comment-column: 40 // c-file-style: "senf" // indent-tabs-mode: nil // ispell-local-dictionary: "american" // compile-command: "scons -u test" // End: