Open Lighting Architecture  Latest Git
OlaDaemon.h
1 /*
2  * This program is free software; you can redistribute it and/or modify
3  * it under the terms of the GNU General Public License as published by
4  * the Free Software Foundation; either version 2 of the License, or
5  * (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU Library General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software
14  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
15  *
16  * OlaDaemon.h
17  * The OLA Daemon class.
18  * Copyright (C) 2005 Simon Newton
19  */
20 
21 #ifndef OLAD_OLADAEMON_H_
22 #define OLAD_OLADAEMON_H_
23 
24 #include <memory>
25 #include <string>
26 #include <vector>
27 #include "ola/Constants.h"
28 #include "ola/ExportMap.h"
29 #include "ola/base/Macro.h"
30 #include "ola/io/SelectServer.h"
32 #include "olad/OlaServer.h"
33 
34 namespace ola {
35 
36 class OlaDaemon {
37  public:
43  OlaDaemon(const OlaServer::Options &options,
44  ExportMap *export_map = NULL);
45 
49  ~OlaDaemon();
50 
55  bool Init();
56 
60  void Shutdown();
61 
65  void Run();
66 
73 
79 
84  OlaServer *GetOlaServer() const { return m_server.get(); }
85 
86 
87  static const unsigned int DEFAULT_RPC_PORT = OLA_DEFAULT_PORT;
88 
89  private:
90  const OlaServer::Options m_options;
91  class ExportMap *m_export_map;
93  std::vector<class PluginLoader*> m_plugin_loaders;
94 
95  // Populated in Init()
96  std::auto_ptr<class PreferencesFactory> m_preferences_factory;
97  std::auto_ptr<OlaServer> m_server;
98 
99  std::string DefaultConfigDir();
100  bool InitConfigDir(const std::string &path);
101 
102  static const char OLA_CONFIG_DIR[];
103  static const char CONFIG_DIR_KEY[];
104  static const char UID_KEY[];
105  static const char USER_NAME_KEY[];
106  static const char GID_KEY[];
107  static const char GROUP_NAME_KEY[];
108 
110 };
111 } // namespace ola
112 #endif // OLAD_OLADAEMON_H_
Represents Socket Addresses.
#define DISALLOW_COPY_AND_ASSIGN(TypeName)
Creates dummy copy constructor and assignment operator declarations.
Definition: Macro.h:44
A container for the exported variables.
Definition: ExportMap.h:324
OlaDaemon(const OlaServer::Options &options, ExportMap *export_map=NULL)
Create a new OlaDaemon.
Definition: OlaDaemon.cpp:71
void Shutdown()
Shutdown the daemon.
Definition: OlaDaemon.cpp:147
void Run()
Run the daemon.
Definition: OlaDaemon.cpp:153
Export variables on the http server.
Constants used throughout OLA.
Options for the OlaServer.
Definition: OlaServer.h:66
static const int OLA_DEFAULT_PORT
The default port which olad listens on for incoming RPC connections.
Definition: Constants.h:68
~OlaDaemon()
Destroy this object.
Definition: OlaDaemon.cpp:98
Definition: OlaDaemon.h:36
OlaServer * GetOlaServer() const
Get the OlaServer the daemon is using.
Definition: OlaDaemon.h:84
bool Init()
Initialise the daemon.
Definition: OlaDaemon.cpp:102
The main OlaServer class.
Definition: OlaServer.h:61
A single threaded I/O event management system.
Definition: SelectServer.h:63
Helper macros.
ola::io::SelectServer * GetSelectServer()
Get the SelectServer the daemon is using.
Definition: OlaDaemon.h:78
The namespace containing all OLA symbols.
Definition: Credentials.cpp:44
ola::network::GenericSocketAddress RPCAddress() const
Return the socket address the RPC server is listening on.
Definition: OlaDaemon.cpp:157
a Generic Socket Address
Definition: SocketAddress.h:166