1*1c78a5d6SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*1c78a5d6SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*1c78a5d6SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*1c78a5d6SAndrew Rist  * distributed with this work for additional information
6*1c78a5d6SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*1c78a5d6SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*1c78a5d6SAndrew Rist  * "License"); you may not use this file except in compliance
9*1c78a5d6SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*1c78a5d6SAndrew Rist  *
11*1c78a5d6SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*1c78a5d6SAndrew Rist  *
13*1c78a5d6SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*1c78a5d6SAndrew Rist  * software distributed under the License is distributed on an
15*1c78a5d6SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*1c78a5d6SAndrew Rist  * KIND, either express or implied.  See the License for the
17*1c78a5d6SAndrew Rist  * specific language governing permissions and limitations
18*1c78a5d6SAndrew Rist  * under the License.
19*1c78a5d6SAndrew Rist  *
20*1c78a5d6SAndrew Rist  *************************************************************/
21*1c78a5d6SAndrew Rist 
22*1c78a5d6SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #ifndef ADC_ADC_CMD_HXX
25cdf0e10cSrcweir #define ADC_ADC_CMD_HXX
26cdf0e10cSrcweir 
27cdf0e10cSrcweir 
28cdf0e10cSrcweir 
29cdf0e10cSrcweir // USED SERVICES
30cdf0e10cSrcweir 	// BASE CLASSES
31cdf0e10cSrcweir #include <cosv/comdline.hxx>
32cdf0e10cSrcweir 	// COMPONENTS
33cdf0e10cSrcweir 	// PARAMETERS
34cdf0e10cSrcweir 
35cdf0e10cSrcweir 
36cdf0e10cSrcweir namespace autodoc
37cdf0e10cSrcweir {
38cdf0e10cSrcweir namespace command
39cdf0e10cSrcweir {
40cdf0e10cSrcweir 
41cdf0e10cSrcweir /** Context for a command, which can be read from the command line.
42cdf0e10cSrcweir */
43cdf0e10cSrcweir class Context
44cdf0e10cSrcweir {
45cdf0e10cSrcweir   public:
46cdf0e10cSrcweir     typedef StringVector::const_iterator opt_iter;
47cdf0e10cSrcweir 
~Context()48cdf0e10cSrcweir     virtual             ~Context() {}
49cdf0e10cSrcweir 
50cdf0e10cSrcweir     void                Init(
51cdf0e10cSrcweir                             opt_iter &          it,
52cdf0e10cSrcweir                             opt_iter            itEnd );
53cdf0e10cSrcweir   private:
54cdf0e10cSrcweir     virtual void        do_Init(
55cdf0e10cSrcweir                             opt_iter &          it,
56cdf0e10cSrcweir                             opt_iter            itEnd ) = 0;
57cdf0e10cSrcweir };
58cdf0e10cSrcweir 
59cdf0e10cSrcweir // IMPLEMENTATION
60cdf0e10cSrcweir inline void
Init(opt_iter & i_nCurArgsBegin,opt_iter i_nEndOfAllArgs)61cdf0e10cSrcweir Context::Init( opt_iter &          i_nCurArgsBegin,
62cdf0e10cSrcweir                opt_iter            i_nEndOfAllArgs )
63cdf0e10cSrcweir 
64cdf0e10cSrcweir { do_Init(i_nCurArgsBegin, i_nEndOfAllArgs); }
65cdf0e10cSrcweir 
66cdf0e10cSrcweir 
67cdf0e10cSrcweir 
68cdf0e10cSrcweir /** Interface for commands, autodoc is able to perform.
69cdf0e10cSrcweir */
70cdf0e10cSrcweir class Command : public Context
71cdf0e10cSrcweir {
72cdf0e10cSrcweir   public:
73cdf0e10cSrcweir     /** Running ranks of the commands are to be maintained at one location:
74cdf0e10cSrcweir         Here!
75cdf0e10cSrcweir     */
76cdf0e10cSrcweir     enum E_Ranks
77cdf0e10cSrcweir     {
78cdf0e10cSrcweir         rank_Load       = 10,
79cdf0e10cSrcweir         rank_Parse      = 20,
80cdf0e10cSrcweir         rank_Save       = 30,
81cdf0e10cSrcweir         rank_CreateHtml = 40,
82cdf0e10cSrcweir         rank_CreateXml  = 50
83cdf0e10cSrcweir     };
84cdf0e10cSrcweir 
85cdf0e10cSrcweir 
86cdf0e10cSrcweir     bool                Run() const;
87cdf0e10cSrcweir     int                 RunningRank() const;
88cdf0e10cSrcweir 
89cdf0e10cSrcweir   private:
90cdf0e10cSrcweir     virtual bool        do_Run() const = 0;
91cdf0e10cSrcweir     virtual int         inq_RunningRank() const = 0;
92cdf0e10cSrcweir };
93cdf0e10cSrcweir 
94cdf0e10cSrcweir // IMPLEMENTATION
95cdf0e10cSrcweir inline bool
Run() const96cdf0e10cSrcweir Command::Run() const
97cdf0e10cSrcweir { return do_Run(); }
98cdf0e10cSrcweir inline int
RunningRank() const99cdf0e10cSrcweir Command::RunningRank() const
100cdf0e10cSrcweir { return inq_RunningRank(); }
101cdf0e10cSrcweir 
102cdf0e10cSrcweir 
103cdf0e10cSrcweir 
104cdf0e10cSrcweir 
105cdf0e10cSrcweir /** The exception thrown, if the command line is invalid.
106cdf0e10cSrcweir */
107cdf0e10cSrcweir class X_CommandLine
108cdf0e10cSrcweir {
109cdf0e10cSrcweir   public:
X_CommandLine(const char * i_sExplanation)110cdf0e10cSrcweir                         X_CommandLine(
111cdf0e10cSrcweir                             const char *        i_sExplanation )
112cdf0e10cSrcweir                             :   sExplanation(i_sExplanation) {}
113cdf0e10cSrcweir 
Report(std::ostream & o_rOut)114cdf0e10cSrcweir     void                Report(
115cdf0e10cSrcweir                             std::ostream &      o_rOut )
116cdf0e10cSrcweir                             { o_rOut << "Error in command line: "
117cdf0e10cSrcweir                                      << sExplanation << Endl(); }
118cdf0e10cSrcweir   private:
119cdf0e10cSrcweir     String              sExplanation;
120cdf0e10cSrcweir };
121cdf0e10cSrcweir 
122cdf0e10cSrcweir 
123cdf0e10cSrcweir 
124cdf0e10cSrcweir 
125cdf0e10cSrcweir }   // namespace command
126cdf0e10cSrcweir }   // namespace autodoc
127cdf0e10cSrcweir #endif
128