CLI  2.9
io_mux.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 
33 #ifndef _CLI_IO_MUX_H_
34 #define _CLI_IO_MUX_H_
35 
36 #include "cli/namespace.h"
37 #include "cli/io_device.h"
38 #include "cli/shell.h"
39 #include "cli/tk.h"
40 
41 
43 
44 
45  class IOMux : public IODevice
53  {
54  public:
56  explicit IOMux(
57  const bool AutoDelete
58  );
59 
61  virtual ~IOMux(void);
62 
63  private:
65  explicit IOMux(void);
67  IOMux(const IOMux&);
69  IOMux& operator=(const IOMux&);
70 
71  // Outputdevice and IODevice interfaces.
72  protected:
73  // Inherit doxygen comments from cli::OutputDevice interface documentation.
74  virtual const bool OpenDevice(void);
75  // Inherit doxygen comments from cli::OutputDevice interface documentation.
76  virtual const bool CloseDevice(void);
77  public:
78  // Inherit doxygen comments from cli::OutputDevice interface documentation.
79  virtual void PutString(const char* const STR_Out) const;
80  // Inherit doxygen comments from cli::OutputDevice interface documentation.
81  virtual void Beep(void) const;
82  // Inherit doxygen comments from cli::OutputDevice interface documentation.
83  virtual void CleanScreen(void) const;
84  // Inherit doxygen comments from cli::OutputDevice interface documentation.
85  virtual const bool WouldOutput(const OutputDevice& CLI_Device) const;
86  // Inherit doxygen comments from cli::IODevice interface documentation.
87  virtual const KEY GetKey(void) const;
88  // Inherit doxygen comments from cli::IODevice interface documentation.
89  virtual const ResourceString GetLocation(void) const;
90  // Inherit doxygen comments from cli::IODevice interface documentation.
91  virtual const bool WouldInput(const IODevice& CLI_Device) const;
92 
93  public:
96  const bool AddDevice(
97  IODevice* const PCLI_Device
98  );
99 
102  const IODevice* const GetCurrentDevice(void) const;
103 
106  const IODevice* const SwitchNextDevice(void);
107 
110  const bool ResetDeviceList(void);
111 
112  protected:
117  virtual IODevice* const CreateDevice(void);
118 
119  private:
124  IODevice* const CheckCurrentDevice(void) const;
125 
128  const bool ReleaseFirstDevice(void);
129 
130  private:
132  mutable tk::Queue<IODevice*> m_qDevices;
133  };
134 
136 
137 #endif // _CLI_IO_MUX_H_
virtual const ResourceString GetLocation(void) const
Input location accessor.
const IODevice *const GetCurrentDevice(void) const
Current device accessor.
Main namespace of the CLI library.
Shell class definition.
virtual void Beep(void) const
Beep handler.
virtual IODevice *const CreateDevice(void)
Method called when an input / output device is needed.
const IODevice *const SwitchNextDevice(void)
Switch to next device.
#define CLI_NS_END(__ns)
End a namespace definition.
Definition: namespace.h:45
ResourceString class.
virtual const bool WouldInput(const IODevice &CLI_Device) const
Stack overflow protection.
virtual const KEY GetKey(void) const
Input key capture handler.
Namespace management.
const bool ResetDeviceList(void)
Reset device list.
Generic output device.
Definition: io_device.h:256
enum _KEY KEY
Input keys.
const bool AddDevice(IODevice *const PCLI_Device)
Device addition in the list.
virtual ~IOMux(void)
Destructor.
#define CLI_NS_BEGIN(__ns)
Begin a namespace definition.
Definition: namespace.h:38
virtual void CleanScreen(void) const
Clean screen.
OutputDevice, IODevice and IOEndl classes defintion.
virtual const bool CloseDevice(void)
Device closure handler.
CLI toolkit definition.
Input / output device multiplexer.
Definition: io_mux.h:52
Generic input/output device.
Definition: io_device.h:581
virtual const bool OpenDevice(void)
Device opening handler.
virtual const bool WouldOutput(const OutputDevice &CLI_Device) const
Stack overflow protection.
virtual void PutString(const char *const STR_Out) const
Output handler.