Lumiera  0.pre.03
»edit your freedom«
subsys.hpp
Go to the documentation of this file.
1 /*
2  SUBSYS.hpp - interface for describing an application part to be handled by main()
3 
4  Copyright (C) Lumiera.org
5  2008, Hermann Vosseler <Ichthyostega@web.de>
6 
7  This program is free software; you can redistribute it and/or
8  modify it under the terms of the GNU General Public License as
9  published by the Free Software Foundation; either version 2 of
10  the License, or (at your option) any later version.
11 
12  This program is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU General Public License for more details.
16 
17  You should have received a copy of the GNU General Public License
18  along with this program; if not, write to the Free Software
19  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 
21 */
22 
43 #ifndef LUMIERA_SUBSYS_H
44 #define LUMIERA_SUBSYS_H
45 
46 #include "lib/error.hpp"
47 #include "lib/nocopy.hpp"
48 
49 #include <functional>
50 #include <string>
51 #include <vector>
52 
53 
54 
55 namespace lumiera {
56 
57  using std::string;
58  using std::function;
59 
60  class Option;
61 
62 
63 
70  class Subsys
72  {
73  public:
74  typedef function<void(string*)> SigTerm;
75 
76  virtual ~Subsys();
77 
79  virtual operator string() const =0;
80 
81 
84  Subsys& depends (Subsys& prereq);
85 
88  bool isRunning() noexcept;
89 
90 
95  virtual bool shouldStart (lumiera::Option&) =0;
96 
97 
107  virtual bool start (lumiera::Option& options, SigTerm) =0;
108 
109 
116  virtual void triggerShutdown() noexcept =0;
117 
118 
119  const std::vector<Subsys*>
120  getPrerequisites() { return prereq_; }
121 
122 
123  private:
129  virtual bool checkRunningState() noexcept =0;
130 
131  std::vector<Subsys*> prereq_;
132  };
133 
134 
135 
136 } // namespace lumiera
137 
138 #endif
Dependencies and lifecycle of a partially independent Subsystem of the Application.
Definition: subsys.hpp:70
Any copy and copy construction prohibited.
Definition: nocopy.hpp:46
Frontend for handling the Lumiera application commandline arguments.
Definition: option.hpp:77
virtual bool start(lumiera::Option &options, SigTerm)=0
attempt to bring up this subsystem up.
Subsys & depends(Subsys &prereq)
define a dependency to another Subsys required for running this subsystem
Definition: subsys.cpp:50
Mix-Ins to allow or prohibit various degrees of copying and cloning.
virtual void triggerShutdown() noexcept=0
initiate termination of this subsystem.
virtual bool checkRunningState() noexcept=0
whether this subsystem is actually operational.
bool isRunning() noexcept
Definition: subsys.cpp:59
Lumiera error handling (C++ interface).
Lumiera public interface.
Definition: advice.cpp:113
virtual bool shouldStart(lumiera::Option &)=0
query application option state to determine if this subsystem should be activated.