SubscriberImpl.h 2.09 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_SUBSCRIBERIMPL_H_
#define CAMEO_SUBSCRIBERIMPL_H_

#include <string>
#include <vector>
22
23
#include "SocketWaitingImpl.h"
#include "zmq.hpp"
legoc's avatar
legoc committed
24
25
26
27
28
29
30
31
32
33
34
35

namespace cameo {

class Server;

class SubscriberImpl {

public:
	SubscriberImpl(const Server * server, const std::string & url, int publisherPort, int synchronizerPort, const std::string& publisherName, int numberOfSubscribers, const std::string& instanceName, int instanceId, const std::string& instanceEndpoint, const std::string& statusEndpoint);
	~SubscriberImpl();

	void init();
36
37
38
39

	bool isEnded() const;
	bool isCanceled() const;

legoc's avatar
legoc committed
40
41
42
43
44
45
	bool receiveBinary(std::string& data);
	bool receive(std::string& data);
	bool receive(std::vector<int32_t>& data);
	bool receive(std::vector<int64_t>& data);
	bool receive(std::vector<float>& data);
	bool receive(std::vector<double>& data);
46
	bool receiveTwoBinaryParts(std::string& data1, std::string& data2);
legoc's avatar
legoc committed
47
48
49
50
51
52
53
54
55
56
57
58
59

	WaitingImpl * waiting();

	const Server * m_server;
	std::string m_url;
	int m_publisherPort;
	int m_synchronizerPort;
	std::string m_publisherName;
	int m_numberOfSubscribers;
	std::string m_instanceName;
	int m_instanceId;
	std::string m_instanceEndpoint;
	std::string m_statusEndpoint;
legoc's avatar
legoc committed
60
	std::unique_ptr<zmq::socket_t> m_subscriber;
legoc's avatar
legoc committed
61
	std::string m_cancelEndpoint;
legoc's avatar
legoc committed
62
	std::unique_ptr<zmq::socket_t> m_cancelPublisher;
63
64
	bool m_ended;
	bool m_canceled;
legoc's avatar
legoc committed
65
66
67
68
69
70
71
72
73
74
75

	static const std::string SYNC;
	static const std::string STREAM;
	static const std::string ENDSTREAM;
	static const std::string CANCEL;
	static const std::string STATUS;
};

}

#endif