CLI  2.9
element.h
Go to the documentation of this file.
1 /*
2  Copyright (c) 2006-2018, Alexis Royer, http://alexis.royer.free.fr/CLI
3 
4  All rights reserved.
5 
6  Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
7 
8  * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
9  * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation
10  and/or other materials provided with the distribution.
11  * Neither the name of the CLI library project nor the names of its contributors may be used to endorse or promote products derived from this software
12  without specific prior written permission.
13 
14  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
15  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
16  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
17  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
18  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
19  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
20  PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
21  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
22  LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
23  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */
26 
27 
31 
32 #ifndef _CLI_ELEMENT_H_
33 #define _CLI_ELEMENT_H_
34 
35 #include "cli/namespace.h"
36 #include "cli/object.h"
37 #include "cli/help.h"
38 #include "cli/tk.h"
39 
40 
42 
43  // Forward declarations.
44  class Cli;
45  class Shell;
46  class OutputDevice;
47  class Element;
48  class Help;
49 
50 
55  class Element : public Object
56  {
57  public:
58  // Typedefs.
61  typedef tk::Queue<const Element*> List;
64  typedef tk::Map<const tk::String, const Element*> Map;
65 
66  public:
68  explicit Element(
69  const char* const STR_Keyword,
70  const Help& STR_Help
71  );
72 
76  virtual ~Element(void) = 0;
77 
78  private:
80  explicit Element(void);
82  Element(const Element&);
84  Element& operator=(const Element&);
85 
86  public:
89  virtual const tk::String GetKeyword(void) const;
90 
93  virtual const Help& GetHelp(void) const;
94 
95  // Note: use of @param doxygen tag in order to avoid doxygen warnings for reimplementations in sub-classes.
104  virtual const bool FindElements(Element::List& CLI_ExactList, Element::List& CLI_NearList, const char* const STR_Keyword) const;
105 
106  // Note: use of @param doxygen tag in order to avoid doxygen warnings for reimplementations in sub-classes.
112  virtual void SetCli(Cli& CLI_Cli);
113 
116  Cli& GetCli(void);
119  const Cli& GetCli(void) const;
120 
124  Shell& GetShell(void) const;
125 
128  const OutputDevice& GetOutputStream(void) const;
129 
132  const OutputDevice& GetErrorStream(void) const;
133 
134  private:
136  const tk::String m_strKeyword;
138  const Help m_cliHelp;
140  Cli* m_pcliCli;
141  };
142 
144 
145 #endif // _CLI_ELEMENT_H_
146 
Generic object.
Definition: object.h:42
Main namespace of the CLI library.
Help container class.
Definition: help.h:46
Cli & GetCli(void)
Read-Write Cli reference accessor.
virtual const bool FindElements(Element::List &CLI_ExactList, Element::List &CLI_NearList, const char *const STR_Keyword) const
Sub-elements search.
#define CLI_NS_END(__ns)
End a namespace definition.
Definition: namespace.h:45
Namespace management.
const OutputDevice & GetErrorStream(void) const
Error stream reference accessor.
Generic output device.
Definition: io_device.h:256
tk::Map< const tk::String, const Element * > Map
CLI element map type.
Definition: element.h:64
Generic CLI element.
Definition: element.h:55
#define CLI_NS_BEGIN(__ns)
Begin a namespace definition.
Definition: namespace.h:38
const OutputDevice & GetOutputStream(void) const
Output stream reference accessor.
Shell & GetShell(void) const
Shell reference accessor.
CLI toolkit definition.
Help class definition.
Object class definition.
virtual const Help & GetHelp(void) const
Element help accessor.
CLI definition class.
Definition: cli.h:97
virtual ~Element(void)=0
Destructor.
tk::Queue< const Element * > List
CLI element list type.
Definition: element.h:61
virtual void SetCli(Cli &CLI_Cli)
Cli reference setting.
virtual const tk::String GetKeyword(void) const
String identifier accessor.
Shell management.
Definition: shell.h:50