Fledge
An open source edge computing platform for industrial users
service_record.h
1 #ifndef _SERVICE_RECORD_H
2 #define _SERVICE_RECORD_H
3 /*
4  * Fledge storage service.
5  *
6  * Copyright (c) 2017 OSisoft, LLC
7  *
8  * Released under the Apache 2.0 Licence
9  *
10  * Author: Mark Riddoch
11  */
12 #include <json_provider.h>
13 #include <string>
14 
15 class ServiceRecord : public JSONProvider {
16  public:
17  ServiceRecord(const std::string& name);
18  ServiceRecord(const std::string& name,
19  const std::string& type);
20  ServiceRecord(const std::string& name,
21  const std::string& type,
22  const std::string& protocol,
23  const std::string& address,
24  const unsigned short port,
25  const unsigned short managementPort,
26  const std::string& token = "");
27  void asJSON(std::string &) const;
28  const std::string& getName() const
29  {
30  return m_name;
31  }
32  const std::string& getType() const
33  {
34  return m_type;
35  }
36  void setAddress(const std::string& address)
37  {
38  m_address = address;
39  }
40  void setPort(const unsigned short port)
41  {
42  m_port = port;
43  }
44  void setProtocol(const std::string& protocol)
45  {
46  m_protocol = protocol;
47  }
48  const std::string& getProtocol() const
49  {
50  return m_protocol;
51  }
52  void setManagementPort(const unsigned short managementPort)
53  {
54  m_managementPort = managementPort;
55  }
56  const std::string& getAddress()
57  {
58  return m_address;
59  }
60  unsigned short getPort()
61  {
62  return m_port;
63  }
64  bool operator==(const ServiceRecord& b) const
65  {
66  return m_name.compare(b.m_name) == 0
67  && m_type.compare(b.m_type) == 0
68  && m_protocol.compare(b.m_protocol) == 0
69  && m_address.compare(b.m_address) == 0
70  && m_port == b.m_port
71  && m_managementPort == b.m_managementPort;
72  }
73  private:
74  std::string m_name;
75  std::string m_type;
76  std::string m_protocol;
77  std::string m_address;
78  unsigned short m_port;
79  unsigned short m_managementPort;
80  std::string m_token; // token set by core server at service start
81 };
82 
83 #endif
void asJSON(std::string &) const
Serialise the service record to json.
Definition: service_record.cpp:63
Definition: json_provider.h:14
Definition: service_record.h:15