UniSet 2.32.1
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{
55 //----------------------------------------------------------------------------------------
56 class UniSetActivator;
57 typedef std::shared_ptr<UniSetActivator> UniSetActivatorPtr;
58 //----------------------------------------------------------------------------------------
72 public UniSetManager
73#ifndef DISABLE_REST_API
75#endif
76 {
77 public:
78
79 static UniSetActivatorPtr Instance();
80
81 virtual ~UniSetActivator();
82
83 // запуск системы
84 // async = true - асинхронный запуск (создаётся отдельный поток).
85 // terminate_control = true - управление процессом завершения (обработка сигналов завершения)
86 void run( bool async, bool terminate_control = true );
87
88 // штатное завершение работы
89 void shutdown();
90
91 // ожидание завершения (если был запуск run(true))
92 void join();
93
94 // прерывание работы
95 void terminate();
96
97 virtual uniset::ObjectType getType() override
98 {
99 return uniset::ObjectType("UniSetActivator");
100 }
101
102
103#ifndef DISABLE_REST_API
104 // Поддержка REST API (IHttpRequestRegistry)
105 virtual Poco::JSON::Object::Ptr httpGetByName( const std::string& name, const Poco::URI::QueryParameters& p ) override;
106 virtual Poco::JSON::Array::Ptr httpGetObjectsList( const Poco::URI::QueryParameters& p ) override;
107 virtual Poco::JSON::Object::Ptr httpHelpByName( const std::string& name, const Poco::URI::QueryParameters& p ) override;
108 virtual Poco::JSON::Object::Ptr httpRequestByName( const std::string& name, const std::string& req, const Poco::URI::QueryParameters& p ) override;
109#endif
110
111 protected:
112
113 void mainWork();
114
115 // уносим в protected, т.к. Activator должен быть только один..
117
118 static std::shared_ptr<UniSetActivator> inst;
119
120 private:
121 void init();
122 static void on_finish_timeout();
123 static void set_signals( bool set );
124
125 std::shared_ptr< OmniThreadCreator<UniSetActivator> > orbthr;
126
127 CORBA::ORB_var orb;
128 bool termControl = { true };
129
130#ifndef DISABLE_REST_API
131 std::shared_ptr<uniset::UHttp::UHttpServer> httpserv;
132 std::string httpHost = { "" };
133 int httpPort = { 0 };
134 std::string httpCORS_allow = { "*" };
135#endif
136 };
137 // -------------------------------------------------------------------------
138} // end of uniset namespace
139//----------------------------------------------------------------------------------------
140#endif
141//----------------------------------------------------------------------------------------
Definition UHttpRequestHandler.h:110
Definition UniSetActivator.h:76
void shutdown()
Definition UniSetActivator.cc:196
virtual Poco::JSON::Array::Ptr httpGetObjectsList(const Poco::URI::QueryParameters &p) override
Definition UniSetActivator.cc:416
Definition UniSetManager.h:60
Definition Calibration.h:27
string< SizeOfObjectType > ObjectType
Definition UniSetTypes_i.idl:33