Strings.h 2.08 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_STRINGS_H_
#define CAMEO_STRINGS_H_

#include <string>
#include <vector>
22
#include <optional>
legoc's avatar
legoc committed
23
24
25
26
27
28
29
30

namespace cameo {

std::vector<std::string> split(const std::string& str, char c);

class Endpoint {

public:
31
	Endpoint(const std::string& protocol, const std::string& address, int port);
legoc's avatar
legoc committed
32
33
	Endpoint(const std::string& address, int port);

34
	const std::string& getProtocol() const;
legoc's avatar
legoc committed
35
36
37
38
39
40
41
42
	const std::string& getAddress() const;
	int getPort() const;

	static Endpoint parse(const std::string& str);

	std::string toString() const;

private:
43
	std::string m_protocol;
legoc's avatar
legoc committed
44
45
46
47
	std::string m_address;
	int m_port;
};

48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
class ApplicationIdentity {

public:
	ApplicationIdentity(const std::string& name, int id, const Endpoint& endpoint);
	ApplicationIdentity(const std::string& name, const Endpoint& endpoint);

	const std::string& getName() const;
	const std::optional<int>& getId() const;
	const Endpoint& getEndpoint() const;

	std::string toJSONString() const;

private:
	std::string m_name;
	std::optional<int> m_id;
	Endpoint m_endpoint;
};

class ApplicationWithStarterIdentity {

public:
	ApplicationWithStarterIdentity(const ApplicationIdentity& application, const ApplicationIdentity& starter);
	ApplicationWithStarterIdentity(const ApplicationIdentity& application);

	const ApplicationIdentity& getApplication() const;
	const std::optional<ApplicationIdentity>& getStarter() const;

	std::string toJSONString() const;

private:
	ApplicationIdentity m_application;
	std::optional<ApplicationIdentity> m_starter;
};

legoc's avatar
legoc committed
82
83
84
}

#endif