Fix documentation build under maverick (doxygen 1.7.1)
[senf.git] / senf / Utils / Console / Server.cci
1 // $Id$
2 //
3 // Copyright (C) 2008
4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
5 // Competence Center NETwork research (NET), St. Augustin, GERMANY
6 //     Stefan Bund <g0dil@berlios.de>
7 //
8 // This program is free software; you can redistribute it and/or modify
9 // it under the terms of the GNU General Public License as published by
10 // the Free Software Foundation; either version 2 of the License, or
11 // (at your option) any later version.
12 //
13 // This program is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 // GNU General Public License for more details.
17 //
18 // You should have received a copy of the GNU General Public License
19 // along with this program; if not, write to the
20 // Free Software Foundation, Inc.,
21 // 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
22
23 /** \file
24     \brief Server inline non-template implementation */
25
26 #include "Server.ih"
27
28 // Custom includes
29
30 #define prefix_ inline
31 //-/////////////////////////////////////////////////////////////////////////////////////////////////
32
33 //-/////////////////////////////////////////////////////////////////////////////////////////////////
34 // senf::console::detail::ServerManager
35
36 prefix_ void senf::console::detail::ServerManager::add(ptr server)
37 {
38     instance().servers_.insert(server);
39 }
40
41 prefix_ void senf::console::detail::ServerManager::remove(ptr server)
42 {
43     instance().servers_.erase(instance().servers_.find(server));
44 }
45
46 prefix_ senf::console::detail::ServerManager & senf::console::detail::ServerManager::instance()
47 {
48     static ServerManager manager;
49     return manager;
50 }
51
52 //-/////////////////////////////////////////////////////////////////////////////////////////////////
53 // senf::console::detail::NonblockingSocketSink
54
55 prefix_ senf::console::detail::NonblockingSocketSink::NonblockingSocketSink(Client & client)
56     : client_ (client)
57 {}
58
59 prefix_ senf::console::Client & senf::console::detail::NonblockingSocketSink::client()
60     const
61 {
62     return client_;
63 }
64
65 //-/////////////////////////////////////////////////////////////////////////////////////////////////
66 // senf::console::Server
67
68 prefix_ senf::console::Server & senf::console::Server::name(std::string const & name)
69 {
70     name_ = name;
71     return *this;
72 }
73
74 prefix_ std::string const & senf::console::Server::name()
75     const
76 {
77     return name_;
78 }
79
80 prefix_ senf::console::DirectoryNode & senf::console::Server::root()
81     const
82 {
83     return *root_;
84 }
85
86 prefix_ senf::console::Server & senf::console::Server::root(DirectoryNode & root)
87 {
88     root_ = root.thisptr();
89     return *this;
90 }
91
92 prefix_ senf::console::Server & senf::console::Server::mode(Mode m)
93 {
94     mode_ = m;
95     return *this;
96 }
97
98 prefix_ senf::console::Server::Mode senf::console::Server::mode()
99     const
100 {
101     return mode_;
102 }
103
104 prefix_ void senf::console::Server::stop()
105 {
106     // commit suicide
107     detail::ServerManager::remove(boost::intrusive_ptr<Server>(this));
108 }
109
110 //-/////////////////////////////////////////////////////////////////////////////////////////////////
111 // senf::console::Client
112
113 prefix_ senf::console::Client::~Client()
114 {
115     stream() << std::flush;
116 }
117
118 prefix_ void senf::console::Client::stop()
119 {
120     // THIS COMMITS SUICIDE. THE INSTANCE IS GONE AFTER removeClient RETURNS
121     server_.removeClient(*this);
122 }
123
124 prefix_ std::string const & senf::console::Client::name()
125     const
126 {
127     return name_;
128 }
129
130 prefix_ std::string senf::console::Client::promptString()
131     const
132 {
133     return name_ + ":" + executor_.cwdPath() + "$";
134 }
135
136 prefix_ senf::console::DirectoryNode & senf::console::Client::root()
137     const
138 {
139     return server_.root();
140 }
141
142 prefix_ senf::console::DirectoryNode & senf::console::Client::cwd()
143     const
144 {
145     return executor_.cwd();
146 }
147
148 prefix_ senf::console::Server::Mode senf::console::Client::mode()
149     const
150 {
151     return mode_;
152 }
153
154 prefix_ void senf::console::Client::write(std::string const & data)
155     const
156 {
157     reader_->write(data);
158 }
159
160 prefix_ std::string const & senf::console::Client::backtrace()
161     const
162 {
163     return backtrace_;
164 }
165
166 prefix_ unsigned senf::console::Client::width()
167     const
168 {
169     return reader_->width();
170 }
171
172 prefix_ senf::console::Client & senf::console::Client::get(std::ostream & os)
173 {
174     return dynamic_cast<detail::NonblockingSocketOStream&>(os)->client();
175 }
176
177 prefix_ senf::console::Client::ClientHandle senf::console::Client::handle()
178     const
179 {
180     return handle_;
181 }
182
183 prefix_ std::ostream & senf::console::Client::stream()
184 {
185     return out_t::member;
186 }
187
188 //-/////////////////////////////////////////////////////////////////////////////////////////////////
189 // senf::console::detail::ClientReader
190
191 prefix_ senf::console::detail::ClientReader::~ClientReader()
192 {}
193
194 prefix_ senf::console::Client & senf::console::detail::ClientReader::client()
195     const
196 {
197     return client_;
198 }
199
200 prefix_ std::string senf::console::detail::ClientReader::promptString()
201     const
202 {
203     return client().promptString();
204 }
205
206 prefix_ senf::console::detail::ClientReader::ClientHandle senf::console::detail::ClientReader::handle()
207     const
208 {
209     return client().handle();
210 }
211
212 prefix_ std::ostream & senf::console::detail::ClientReader::stream()
213     const
214 {
215     return client().stream();
216 }
217
218 prefix_ void senf::console::detail::ClientReader::stopClient()
219 {
220     client().stop();
221 }
222
223 prefix_ std::string::size_type
224 senf::console::detail::ClientReader::handleInput(std::string const & input, bool incremental)
225     const
226 {
227     return client().handleInput(input, incremental);
228 }
229
230 prefix_ void senf::console::detail::ClientReader::disablePrompt()
231 {
232     v_disablePrompt();
233 }
234
235 prefix_ void senf::console::detail::ClientReader::enablePrompt()
236 {
237     v_enablePrompt();
238 }
239
240 prefix_ void senf::console::detail::ClientReader::write(std::string const & data)
241 {
242     v_write(data);
243 }
244
245 prefix_ unsigned senf::console::detail::ClientReader::width()
246     const
247 {
248     return v_width();
249 }
250
251 prefix_ senf::console::detail::ClientReader::ClientReader(Client & client)
252     : client_ (client)
253 {}
254
255 //-/////////////////////////////////////////////////////////////////////////////////////////////////
256 #undef prefix_
257
258 \f
259 // Local Variables:
260 // mode: c++
261 // fill-column: 100
262 // comment-column: 40
263 // c-file-style: "senf"
264 // indent-tabs-mode: nil
265 // ispell-local-dictionary: "american"
266 // compile-command: "scons -u test"
267 // End: