Services.h 1.92 KB
Newer Older
legoc's avatar
legoc committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
/*
 * Copyright 2015 Institut Laue-Langevin
 *
 * Licensed under the EUPL, Version 1.1 only (the "License");
 * You may not use this work except in compliance with the Licence.
 * You may obtain a copy of the Licence at:
 *
 * http://joinup.ec.europa.eu/software/page/eupl
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the Licence is distributed on an "AS IS" basis,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the Licence for the specific language governing permissions and
 * limitations under the Licence.
 */

#ifndef CAMEO_SERVICES_H_
#define CAMEO_SERVICES_H_

#include <string>
#include <vector>
22
#include "EventStreamSocket.h"
legoc's avatar
legoc committed
23
#include "OutputStreamSocket.h"
legoc's avatar
legoc committed
24
25
26
27

namespace cameo {

class ServicesImpl;
28
class RequestSocketImpl;
legoc's avatar
legoc committed
29
30
31
32
33
34
35

class Services {

public:
	Services();
	~Services();

36
37
	void terminate();

38
	void init();
39
	void initRequestSocket();
legoc's avatar
legoc committed
40
41
42
43
44
45
	std::vector<std::string> split(const std::string& info);

	void setTimeout(int timeout);
	int getTimeout() const;
	const std::string& getEndpoint() const;
	const std::string& getUrl() const;
legoc's avatar
legoc committed
46
	std::array<int, 3> getVersion() const;
legoc's avatar
legoc committed
47
48
49
50
	int getPort() const;
	const std::string& getStatusEndpoint() const;

	bool isAvailable(int timeout) const;
51
	void retrieveServerVersion();
legoc's avatar
legoc committed
52
	void initStatus();
legoc's avatar
legoc committed
53
	std::unique_ptr<EventStreamSocket> openEventStream();
legoc's avatar
legoc committed
54
55
	int getStreamPort(const std::string& name);
	std::unique_ptr<OutputStreamSocket> createOutputStreamSocket(const std::string& name);
56
	std::unique_ptr<RequestSocketImpl> createRequestSocket(const std::string& endpoint);
57
	std::unique_ptr<RequestSocketImpl> createRequestSocket(const std::string& endpoint, int timeout);
legoc's avatar
legoc committed
58
59

	std::string m_serverEndpoint;
legoc's avatar
legoc committed
60
	std::array<int, 3> m_serverVersion;
legoc's avatar
legoc committed
61
62
63
64
	std::string m_url;
	int m_port;
	int m_statusPort;
	std::string m_serverStatusEndpoint;
legoc's avatar
legoc committed
65
	std::unique_ptr<ServicesImpl> m_impl;
66
	std::unique_ptr<RequestSocketImpl> m_requestSocket;
legoc's avatar
legoc committed
67
68
69
70
71
};

}

#endif