Manual for OpenFLUID 2.1.11

BindingVerboseMachineListener.hpp
Go to the documentation of this file.
1 /*
2 
3  This file is part of OpenFLUID software
4  Copyright(c) 2007, INRA - Montpellier SupAgro
5 
6 
7  == GNU General Public License Usage ==
8 
9  OpenFLUID is free software: you can redistribute it and/or modify
10  it under the terms of the GNU General Public License as published by
11  the Free Software Foundation, either version 3 of the License, or
12  (at your option) any later version.
13 
14  OpenFLUID is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  GNU General Public License for more details.
18 
19  You should have received a copy of the GNU General Public License
20  along with OpenFLUID. If not, see <http://www.gnu.org/licenses/>.
21 
22 
23  == Other Usage ==
24 
25  Other Usage means a use of OpenFLUID that is inconsistent with the GPL
26  license, and requires a written agreement between You and INRA.
27  Licensees for Other Usage of OpenFLUID may use this file in accordance
28  with the terms contained in the written agreement between You and INRA.
29 
30 */
31 
32 /**
33  @file BindingVerboseMachineListener.hpp
34 
35  @author Jean-Christophe FABRE <jean-christophe.fabre@inra.fr>
36 */
37 
38 
39 #ifndef __OPENFLUID_UTILS_BINDINGVERBOSEMACHINELISTENER_HPP__
40 #define __OPENFLUID_UTILS_BINDINGVERBOSEMACHINELISTENER_HPP__
41 
42 
45 
46 
47 namespace openfluid { namespace utils {
48 
49 
51 {
52  private:
53 
55 
56  void displayStatusWithLeftMargin(const openfluid::base::Listener::Status& Status)
57  {
58  switch (Status)
59  {
61  mp_OutErr->printfOut("%14s\n","[Error]");
62  break;
64  mp_OutErr->printfOut("%14s\n","[OK]");
65  break;
67  mp_OutErr->printfOut("%14s\n","[Warning]");
68  break;
69  }
70  };
71 
72  public:
73 
75  openfluid::machine::MachineListener(), mp_OutErr(OutErr)
76  { }
77 
79  { }
80 
81 
83  {
84  switch (Status)
85  {
87  mp_OutErr->printfOut(" [Error]\n");
88  break;
90  mp_OutErr->printfOut(" [OK]\n");
91  break;
93  mp_OutErr->printfOut(" [Warning]\n");
94  break;
95  }
96  }
97 
98 
99  void onInitParams()
100  {
101  mp_OutErr->printfOut("%s","Initializing parameters...");
102  }
103 
105  {
107  }
108 
109 
111  {
112  mp_OutErr->printfOut("%s","Preparing data...");
113  }
114 
116  {
118  }
119 
120 
122  {
123  mp_OutErr->printfOut("%s","Checking consistency...");
124  }
125 
127  {
129  }
130 
131 
133  {
134  mp_OutErr->printfOut("%s","\nInitializing simulation...");
135  }
136 
138  {
140  }
141 
142 
144  {
145  mp_OutErr->printfOut(" Progress Real time Status\n");
146  mp_OutErr->printfOut(" -------- --------- ------\n");
147  }
148 
150  {
151  double Percent = (double(SimStatus->getCurrentTimeIndex())/double(SimStatus->getSimulationDuration()))*100;
152  mp_OutErr->printfOut(" %7.2f%%%27s",Percent,SimStatus->getCurrentDate().getAsISOString().c_str());
153  }
154 
156  {
157  displayStatusWithLeftMargin(Status);
158  }
159 
160 
162  { }
163 
165  {
166  mp_OutErr->printfOut("%s","Finalizing simulation...");
167  }
168 
170  {
172  }
173 
174 };
175 
176 
177 } } // namespaces
178 
179 
180 #endif /* __OPENFLUID_UTILS_BINDINGVERBOSEMACHINELISTENER_HPP__ */
openfluid::utils::BindingVerboseMachineListener::onPrepareDataDone
void onPrepareDataDone(const openfluid::base::Listener::Status &Status)
Definition: BindingVerboseMachineListener.hpp:115
openfluid::utils::BindingVerboseMachineListener::onInitParamsDone
void onInitParamsDone(const openfluid::base::Listener::Status &Status)
Definition: BindingVerboseMachineListener.hpp:104
openfluid::utils::BindingVerboseMachineListener::onCheckConsistencyDone
void onCheckConsistencyDone(const openfluid::base::Listener::Status &Status)
Definition: BindingVerboseMachineListener.hpp:126
openfluid::utils::BindingVerboseMachineListener::onInitParams
void onInitParams()
Definition: BindingVerboseMachineListener.hpp:99
openfluid::machine::MachineListener::MachineListener
MachineListener()=default
openfluid::utils::BindingVerboseMachineListener::onBeforeRunSteps
void onBeforeRunSteps()
Definition: BindingVerboseMachineListener.hpp:143
openfluid::utils::BindingVerboseMachineListener::displayStatus
void displayStatus(const openfluid::base::Listener::Status &Status)
Definition: BindingVerboseMachineListener.hpp:82
openfluid::utils::BindingVerboseMachineListener::onFinalizeRun
void onFinalizeRun()
Definition: BindingVerboseMachineListener.hpp:164
openfluid::base::Listener::LISTEN_WARNING
@ LISTEN_WARNING
Definition: Listener.hpp:54
openfluid::base::SimulationStatus::getSimulationDuration
openfluid::core::Duration_t getSimulationDuration() const
Definition: SimulationStatus.hpp:115
openfluid::utils::BindingAbstractOutErr::printfOut
virtual void printfOut(const char *fmt,...) const =0
openfluid::utils::BindingVerboseMachineListener::onInitializeRun
void onInitializeRun()
Definition: BindingVerboseMachineListener.hpp:132
openfluid::base::SimulationStatus::getCurrentTimeIndex
openfluid::core::TimeIndex_t getCurrentTimeIndex() const
Definition: SimulationStatus.hpp:120
openfluid::utils::BindingVerboseMachineListener::onPrepareData
void onPrepareData()
Definition: BindingVerboseMachineListener.hpp:110
openfluid::utils::BindingVerboseMachineListener::onFinalizeRunDone
void onFinalizeRunDone(const openfluid::base::Listener::Status &Status)
Definition: BindingVerboseMachineListener.hpp:169
openfluid::base::SimulationStatus
Definition: SimulationStatus.hpp:55
openfluid::utils::BindingVerboseMachineListener::BindingVerboseMachineListener
BindingVerboseMachineListener(const openfluid::utils::BindingAbstractOutErr *OutErr)
Definition: BindingVerboseMachineListener.hpp:74
openfluid::utils::BindingVerboseMachineListener::~BindingVerboseMachineListener
~BindingVerboseMachineListener()
Definition: BindingVerboseMachineListener.hpp:78
openfluid
Definition: ApplicationException.hpp:47
openfluid::core::DateTime::getAsISOString
std::string getAsISOString() const
openfluid::utils::BindingVerboseMachineListener::onInitializeRunDone
void onInitializeRunDone(const openfluid::base::Listener::Status &Status)
Definition: BindingVerboseMachineListener.hpp:137
openfluid::base::SimulationStatus::getCurrentDate
openfluid::core::DateTime getCurrentDate() const
Definition: SimulationStatus.hpp:105
openfluid::utils::BindingAbstractOutErr
Definition: BindingAbstractOutErr.hpp:46
openfluid::base::Listener::LISTEN_OK
@ LISTEN_OK
Definition: Listener.hpp:54
openfluid::utils::BindingVerboseMachineListener::onAfterRunSteps
void onAfterRunSteps()
Definition: BindingVerboseMachineListener.hpp:161
openfluid::utils::BindingVerboseMachineListener::onCheckConsistency
void onCheckConsistency()
Definition: BindingVerboseMachineListener.hpp:121
openfluid::machine::MachineListener
Definition: MachineListener.hpp:54
BindingAbstractOutErr.hpp
openfluid::utils::BindingVerboseMachineListener::onRunStepDone
void onRunStepDone(const openfluid::base::Listener::Status &Status)
Definition: BindingVerboseMachineListener.hpp:155
MachineListener.hpp
openfluid::base::Listener::LISTEN_ERROR
@ LISTEN_ERROR
Definition: Listener.hpp:54
openfluid::base::Listener::Status
Status
Definition: Listener.hpp:54
openfluid::utils::BindingVerboseMachineListener::onRunStep
void onRunStep(const openfluid::base::SimulationStatus *SimStatus)
Definition: BindingVerboseMachineListener.hpp:149
openfluid::utils::BindingVerboseMachineListener
Definition: BindingVerboseMachineListener.hpp:50