siplasplas
datamodel.hpp
1 #ifndef SIPLASPLAS_EXAMPLES_REFLECTION_STATIC_PROTOSERIALIZATION_DATAMODEL_HPP
2 #define SIPLASPLAS_EXAMPLES_REFLECTION_STATIC_PROTOSERIALIZATION_DATAMODEL_HPP
3 
4 #include <string>
5 #include <chrono>
6 #include <ostream>
7 
9 {
10 public:
11  std::string ipAddress = "";
12  std::string gateway = "";
13  std::chrono::milliseconds pingInterval = std::chrono::milliseconds(0);
14 };
15 
17 {
18 public:
19  int port = 8080;
20 };
21 
22 class Settings
23 {
24 public:
25  NetworkSettings netwokSettings;
26  ServerSettings serverSettings;
27 };
28 
29 enum class Operation
30 {
31  Set,
32  Get
33 };
34 
36 {
37 public:
38  Operation operation;
39  Settings settings;
40 };
41 
43 {
44 public:
45  Operation operation;
46 };
47 
48 #include <reflection/examples/reflection/static/protoserialization/datamodel.hpp>
49 
50 std::ostream& operator<<(std::ostream& os, const NetworkSettings& networkSettings)
51 {
52  return os << "NetworkSettings {\n"
53  << " ipAddress: " << networkSettings.ipAddress
54  << "\n gateway: " << networkSettings.gateway
55  << "\n pingInterval: " << networkSettings.pingInterval.count() << " ms"
56  << "\n}";
57 }
58 
59 std::ostream& operator<<(std::ostream& os, const ServerSettings& serverSettings)
60 {
61  return os << "ServerSettings {\n"
62  << " port: " << serverSettings.port
63  << "\n}";
64 }
65 
66 std::ostream& operator<<(std::ostream& os, const Settings& settings)
67 {
68  return os << "Settings{\n"
69  << " networkSettings: " << settings.netwokSettings
70  << "\n serverSettings: " << settings.serverSettings
71  << "\n}";
72 }
73 
74 std::ostream& operator<<(std::ostream& os, const Operation& operation)
75 {
76  return os << "Operation::" << cpp::static_reflection::Enum<Operation>::toString(operation);
77 }
78 
79 std::ostream& operator<<(std::ostream& os, const SettingsOperation& settingsOperation)
80 {
81  return os << "SettingsOperation{\n"
82  << " operation: " << settingsOperation.operation
83  << "\n settings: " << settingsOperation.settings
84  << "\n}";
85 }
86 
87 #endif // SIPLASPLAS_EXAMPLES_REFLECTION_STATIC_PROTOSERIALIZATION_DATAMODEL_HPP
Definition: datamodel.hpp:42
Definition: datamodel.hpp:35
Returns static reflection information of the given enumeration type.
Definition: enum.hpp:303
Definition: datamodel.hpp:22
Definition: datamodel.hpp:8
Definition: datamodel.hpp:16