UniSet 2.41.2
UniSetActivator.h
1/*
2 * Copyright (c) 2015 Pavel Vainerman.
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as
6 * published by the Free Software Foundation, version 2.1.
7 *
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * Lesser General Lesser Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16// --------------------------------------------------------------------------
21// --------------------------------------------------------------------------
22#ifndef UniSetActivator_H_
23#define UniSetActivator_H_
24// --------------------------------------------------------------------------
25#include <deque>
26#include <memory>
27#include <omniORB4/CORBA.h>
28#include "UniSetTypes.h"
29#include "UniSetObject.h"
30#include "UniSetManager.h"
31#include "OmniThreadCreator.h"
32#include "UHttpRequestHandler.h"
33#include "UHttpServer.h"
34//----------------------------------------------------------------------------------------
35namespace uniset
36{
56 //----------------------------------------------------------------------------------------
57 class UniSetActivator;
58 typedef std::shared_ptr<UniSetActivator> UniSetActivatorPtr;
59 //----------------------------------------------------------------------------------------
72 class UniSetActivator:
73 public UniSetManager
74#ifndef DISABLE_REST_API
76#endif
77 {
78 public:
79
80 static UniSetActivatorPtr Instance();
81
82 virtual ~UniSetActivator();
83
84 // запуск системы
85 // async = true - асинхронный запуск (создаётся отдельный поток).
86 // terminate_control = true - управление процессом завершения (обработка сигналов завершения)
87 void run( bool async, bool terminate_control = true );
88
89 // штатное завершение работы
90 void shutdown();
91
92 // ожидание завершения (если был запуск run(true))
93 void join();
94
95 // прерывание работы
96 void terminate();
97
98 virtual uniset::ObjectType getType() override
99 {
100 return uniset::ObjectType("UniSetActivator");
101 }
102
103
104#ifndef DISABLE_REST_API
105 // Поддержка REST API (IHttpRequestRegistry)
106 virtual Poco::JSON::Object::Ptr httpGetByName( const std::string& name, const Poco::URI::QueryParameters& p ) override;
107 virtual Poco::JSON::Array::Ptr httpGetObjectsList( const Poco::URI::QueryParameters& p ) override;
108 virtual Poco::JSON::Object::Ptr httpHelpByName( const std::string& name, const Poco::URI::QueryParameters& p ) override;
109 virtual Poco::JSON::Object::Ptr httpRequestByName( const std::string& name, const std::string& req, const Poco::URI::QueryParameters& p ) override;
110#endif
111
112 protected:
113
114 void mainWork();
115
116 // уносим в protected, т.к. Activator должен быть только один..
117 UniSetActivator();
118
119 static std::shared_ptr<UniSetActivator> inst;
120
121 private:
122 void init();
123 static void on_finish_timeout();
124 static void set_signals( bool set );
125
126 std::shared_ptr< OmniThreadCreator<UniSetActivator> > orbthr;
127
128 CORBA::ORB_var orb;
129 bool termControl = { true };
130
131#ifndef DISABLE_REST_API
132 std::shared_ptr<uniset::UHttp::UHttpServer> httpserv;
133 std::string httpHost = { "" };
134 int httpPort = { 0 };
135 std::string httpCORS_allow = { "*" };
136 std::string httpDefaultContentType = { "text/json; charset=UTF-8" };
137#endif
138 };
139 // -------------------------------------------------------------------------
140} // end of uniset namespace
141//----------------------------------------------------------------------------------------
142#endif
143//----------------------------------------------------------------------------------------
Определения UHttpRequestHandler.h:110
Определения UniSetActivator.h:77
void shutdown()
Определения UniSetActivator.cc:198
virtual Poco::JSON::Array::Ptr httpGetObjectsList(const Poco::URI::QueryParameters &p) override
Определения UniSetActivator.cc:418
Определения Calibration.h:27
string< SizeOfObjectType > ObjectType
Определения UniSetTypes_i.idl:33