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)
5  2008, Hermann Vosseler <Ichthyostega@web.de>
6 
7   **Lumiera** is free software; you can redistribute it and/or modify it
8   under the terms of the GNU General Public License as published by the
9   Free Software Foundation; either version 2 of the License, or (at your
10   option) any later version. See the file COPYING for further details.
11 
12 */
13 
34 #ifndef LUMIERA_SUBSYS_H
35 #define LUMIERA_SUBSYS_H
36 
37 #include "lib/error.hpp"
38 #include "lib/nocopy.hpp"
39 
40 #include <functional>
41 #include <string>
42 #include <vector>
43 
44 
45 
46 namespace lumiera {
47 
48  using std::string;
49  using std::function;
50 
51  class Option;
52 
53 
54 
61  class Subsys
63  {
64  public:
65  typedef function<void(string*)> SigTerm;
66 
67  virtual ~Subsys();
68 
70  virtual operator string() const =0;
71 
72 
75  Subsys& depends (Subsys& prereq);
76 
79  bool isRunning() noexcept;
80 
81 
86  virtual bool shouldStart (lumiera::Option&) =0;
87 
88 
98  virtual bool start (lumiera::Option& options, SigTerm) =0;
99 
100 
107  virtual void triggerShutdown() noexcept =0;
108 
109 
110  const std::vector<Subsys*>
111  getPrerequisites() { return prereq_; }
112 
113 
114  private:
120  virtual bool checkRunningState() noexcept =0;
121 
122  std::vector<Subsys*> prereq_;
123  };
124 
125 
126 
127 } // namespace lumiera
128 
129 #endif
Dependencies and lifecycle of a partially independent Subsystem of the Application.
Definition: subsys.hpp:61
Any copy and copy construction prohibited.
Definition: nocopy.hpp:37
Frontend for handling the Lumiera application commandline arguments.
Definition: option.hpp:68
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:41
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:50
Lumiera error handling (C++ interface).
Lumiera public interface.
Definition: advice.cpp:104
virtual bool shouldStart(lumiera::Option &)=0
query application option state to determine if this subsystem should be activated.