Open Lighting Architecture
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
15  *
16  * OlaDaemon.h
17  * Interface for the OLA Daemon class
18  * Copyright (C) 2005-2008 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/BaseTypes.h"
28 #include "ola/ExportMap.h"
29 #include "ola/io/SelectServer.h"
30 #include "ola/network/Socket.h"
31 #include "ola/network/SocketAddress.h"
32 #include "olad/OlaServer.h"
33 
34 namespace ola {
35 namespace rdm {
36  class RootPidStore;
37 } // rdm
38 
41 using std::auto_ptr;
42 
43 class OlaDaemon {
44  public:
45  OlaDaemon(const OlaServer::Options &options,
46  ExportMap *export_map = NULL);
47  ~OlaDaemon();
48  bool Init();
49  void Shutdown();
50  void Run();
51 
53  SelectServer* GetSelectServer() { return &m_ss; }
54  OlaServer *GetOlaServer() const { return m_server.get(); }
55 
56  static const unsigned int DEFAULT_RPC_PORT = OLA_DEFAULT_PORT;
57 
58  private:
59  const OlaServer::Options m_options;
60  class ExportMap *m_export_map;
61  SelectServer m_ss;
62  vector<class PluginLoader*> m_plugin_loaders;
63 
64  auto_ptr<class PreferencesFactory> m_preferences_factory;
65  auto_ptr<class OlaClientServiceFactory> m_service_factory;
66  auto_ptr<TCPAcceptingSocket> m_accepting_socket;
67  auto_ptr<OlaServer> m_server;
68 
69  string DefaultConfigDir();
70  bool InitConfigDir(const string &path);
71 
72  OlaDaemon(const OlaDaemon&);
73  OlaDaemon& operator=(const OlaDaemon&);
74 
75  static const char K_RPC_PORT_VAR[];
76  static const char OLA_CONFIG_DIR[];
77 };
78 } // namespace ola
79 #endif // OLAD_OLADAEMON_H_