replaced some tabs with spaces
[senf.git] / Scheduler / Console / OverloadedCommand.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 OverloadedCommand inline non-template implementation */
25
26 //#include "OverloadedCommand.ih"
27
28 // Custom includes
29
30 #define prefix_ inline
31 ///////////////////////////////cci.p///////////////////////////////////////
32
33 ///////////////////////////////////////////////////////////////////////////
34 // senf::console::OverloadedCommandNode
35
36 prefix_ senf::console::OverloadedCommandNode::ptr senf::console::OverloadedCommandNode::create()
37 {
38     return ptr(new OverloadedCommandNode());
39 }
40
41 prefix_ senf::console::OverloadedCommandNode::ptr senf::console::OverloadedCommandNode::thisptr()
42 {
43     return boost::static_pointer_cast<OverloadedCommandNode>(shared_from_this());
44 }
45
46 prefix_ senf::console::OverloadedCommandNode::cptr senf::console::OverloadedCommandNode::thisptr()
47     const
48 {
49     return boost::static_pointer_cast<OverloadedCommandNode const>(shared_from_this());
50 }
51
52 prefix_ senf::console::OverloadedCommandNode &
53 senf::console::OverloadedCommandNode::doc(std::string const & doc)
54 {
55     doc_ = doc;
56     return *this;
57 }
58
59 prefix_ unsigned
60 senf::console::OverloadedCommandNode::overloadIndex(CommandOverload const & overload)
61 {
62     return find(overloads_.begin(), overloads_.end(), CommandOverload::cptr(&overload)) 
63         - overloads_.begin() + 1;
64 }
65
66 prefix_ senf::console::OverloadedCommandNode::OverloadedCommandNode()
67 {}
68
69 ///////////////////////////////////////////////////////////////////////////
70 // senf::console::CommandOverload
71
72 prefix_ senf::console::CommandOverload::~CommandOverload()
73 {}
74
75 prefix_ void senf::console::CommandOverload::execute(std::ostream & os,
76                                                      ParseCommandInfo const & command)
77 {
78     v_execute(os, command);
79 }
80
81 prefix_ void senf::console::CommandOverload::operator()(std::ostream & os,
82                                                         ParseCommandInfo const & command)
83 {
84     execute(os, command);
85 }
86
87 prefix_ unsigned senf::console::CommandOverload::numArguments()
88     const
89 {
90     return v_numArguments();
91 }
92
93 prefix_ void senf::console::CommandOverload::argumentDoc(unsigned index, ArgumentDoc & doc)
94     const
95 {
96     return v_argumentDoc(index,doc);
97 }
98
99 prefix_ std::string senf::console::CommandOverload::doc()
100     const
101 {
102     return v_doc();
103 }
104
105 prefix_ senf::console::OverloadedCommandNode & senf::console::CommandOverload::node()
106     const
107 {
108     SENF_ASSERT( node_ );
109     return *node_;
110 }
111
112 prefix_ unsigned senf::console::CommandOverload::overloadIndex()
113     const
114 {
115     return node().overloadIndex(*this);
116 }
117
118 prefix_ senf::console::CommandOverload::CommandOverload()
119     : node_(0)
120 {}
121
122 ///////////////////////////////////////////////////////////////////////////
123 // senf::console::SimpleCommandOverload
124
125 prefix_ senf::console::SimpleCommandOverload::ptr
126 senf::console::SimpleCommandOverload::create(Function fn)
127 {
128     return ptr(new SimpleCommandOverload(fn));
129 }
130
131 prefix_ senf::console::SimpleCommandOverload &
132 senf::console::SimpleCommandOverload::doc(std::string const & doc)
133 {
134     doc_ = doc;
135     return *this;
136 }
137
138 prefix_ senf::console::SimpleCommandOverload::SimpleCommandOverload(Function fn)
139     : fn_ (fn)
140 {}
141
142 ///////////////////////////////cci.e///////////////////////////////////////
143 #undef prefix_
144
145 \f
146 // Local Variables:
147 // mode: c++
148 // fill-column: 100
149 // comment-column: 40
150 // c-file-style: "senf"
151 // indent-tabs-mode: nil
152 // ispell-local-dictionary: "american"
153 // compile-command: "scons -u test"
154 // End: