CLI  2.9
ui.cpp
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 
28 #include "cli/pch.h"
29 
30 #include "cli/cli.h"
31 #include "cli/ui.h"
32 #include "cli/shell.h"
33 
34 
36 
37  CLI_NS_BEGIN(ui)
38 
39  UI::UI(void)
40  : ExecutionContext(), m_bExecResult(false)
41  {
42  }
43 
44  UI::UI(ExecutionContext& CLI_ParentContext)
45  : ExecutionContext(CLI_ParentContext), m_bExecResult(false)
46  {
47  }
48 
49  UI::~UI(void)
50  {
51  }
52 
53  const bool UI::GetbExecResult(void) const
54  {
55  return m_bExecResult;
56  }
57 
58  const bool UI::OnStartExecution(void)
59  {
60  m_bExecResult = false;
61  Reset();
63 
64  return true;
65  }
66 
67  const bool UI::OnStopExecution(void)
68  {
69  // If failure, reset the user interface object and manage output.
70  if (! m_bExecResult)
71  {
74  }
75 
76  return true;
77  }
78 
79  void UI::EndControl(const bool B_ExecResult)
80  {
81  // Store execution result.
82  m_bExecResult = B_ExecResult;
83 
84  // Stop execution
86  }
87 
88  CLI_NS_END(ui)
89 
91 
Main namespace of the CLI library.
const bool GetbExecResult(void) const
Execution result accessor.
Definition: ui.cpp:53
Shell class definition.
Echo stream.
Definition: exec_context.h:55
virtual const bool OnStartExecution(void)
Beginning of execution handler.
Definition: ui.cpp:58
#define CLI_NS_END(__ns)
End a namespace definition.
Definition: namespace.h:45
void EndControl(const bool B_ExecResult)
Method to call by child classes in order to end the control execution.
Definition: ui.cpp:79
virtual ~UI(void)
Destructor.
Definition: ui.cpp:49
virtual void ResetToDefault(void)=0
Handler called when default value is required to be restored.
Execution context.
Definition: exec_context.h:149
CLI library default pre-compiled header.
UI class definition.
virtual const bool OnStopExecution(void)
Execution termination handler.
Definition: ui.cpp:67
#define CLI_NS_BEGIN(__ns)
Begin a namespace definition.
Definition: namespace.h:38
UI(void)
Top execution context constructor.
Definition: ui.cpp:39
Cli class definition.
void StopExecution(void)
Terminates this execution context's execution.
Generic user interface class.
Definition: ui.h:60
virtual void Reset(void)=0
Handler called when data reset is required.
const IOEndl endl
The common IOEndl object.
const OutputDevice & GetStream(const STREAM_TYPE E_StreamType) const
Output stream accessor.