ServicesImpl.h 3.61 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
/*
 * 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_SERVICESIMPL_H_
#define CAMEO_SERVICESIMPL_H_

20
#include "zmq.hpp"
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include <vector>
#include <memory>

namespace cameo {

class RequestSocketImpl;

class ServicesImpl {

public:
	ServicesImpl();
	virtual ~ServicesImpl();

	void setTimeout(int timeout);
	int getTimeout() const;

37
	std::string createSyncRequest() const;
legoc's avatar
legoc committed
38
	std::string createSyncStreamRequest(const std::string& name) const;
39
	std::string createVersionRequest() const;
40
41
42
43
	std::string createStartRequest(const std::string& name, const std::vector<std::string> & args, const std::string& instanceReference) const;
	std::string createStopRequest(int id) const;
	std::string createKillRequest(int id) const;
	std::string createConnectRequest(const std::string& name) const;
44
	std::string createConnectWithIdRequest(int id) const;
45
	std::string createIsAliveRequest(int id) const;
46
	std::string createListRequest() const;
legoc's avatar
legoc committed
47
	std::string createAppsRequest() const;
48
	std::string createStreamStatusRequest() const;
49
50
	std::string createSetStatusRequest(int id, int32_t state) const;
	std::string createGetStatusRequest(int id) const;
51
	std::string createSetResultRequest(int id) const;
52
53
54
55
	std::string createSubscribePublisherRequest() const;
	std::string createCreatePublisherRequest(int id, const std::string& name, int numberOfSubscribers) const;
	std::string createConnectPublisherRequest(int id, const std::string& publisherName) const;
	std::string createTerminatePublisherRequest(int id, const std::string& name) const;
56
57
58
59
60
	std::string createRequestPortV0Request(int id, const std::string& name) const;
	std::string createConnectPortV0Request(int id, const std::string& name) const;
	std::string createRemovePortV0Request(int id, const std::string& name) const;
	std::string createAttachUnmanagedRequest(const std::string& name) const;
	std::string createDetachUnmanagedRequest(int id) const;
61
62
	std::string createOutputPortWithIdRequest(int id) const;
	std::string createOutputPortRequest(const std::string& name) const;
63
64
	std::string createRequestResponse(int64_t value) const;
	std::string createRequestResponse(int64_t value, const std::string& message) const;
65
66
67
	std::string createStoreKeyValueRequest(int id, const std::string& key, const std::string& value);
	std::string createGetKeyValueRequest(int id, const std::string& key);
	std::string createRemoveKeyRequest(int id, const std::string& key);
68
69
70
71
72
73
74

	zmq::socket_t * createEventSubscriber(const std::string& endpoint, const std::string& cancelEndpoint);
	zmq::socket_t * createOutputStreamSubscriber(const std::string& endpoint, const std::string& cancelEndpoint);
	zmq::socket_t * createCancelPublisher(const std::string& endpoint);
	zmq::socket_t * createRequestSocket(const std::string& endpoint);

	bool isAvailable(RequestSocketImpl * socket, int timeout);
legoc's avatar
legoc committed
75
76
	void sendSyncStream(RequestSocketImpl * socket, const std::string& name);
	void waitForStreamSubscriber(zmq::socket_t * subscriber, RequestSocketImpl * socket, const std::string& name);
77
78
79
80
81
82
83
84
85
	void waitForSubscriber(zmq::socket_t * subscriber, RequestSocketImpl * socket);

	zmq::context_t m_context;
	int m_timeout;
};

}

#endif