DataStorm  0.1
Data Distribution Service
Node.h
Go to the documentation of this file.
1 // **********************************************************************
2 //
3 // Copyright (c) 2018-present ZeroC, Inc. All rights reserved.
4 //
5 // **********************************************************************
6 
7 #pragma once
8 
9 #include <DataStorm/Config.h>
10 #include <DataStorm/InternalI.h>
11 
12 namespace DataStorm
13 {
14 
15 template<typename, typename, typename> class Topic;
16 
25 class DATASTORM_API NodeShutdownException : public std::exception
26 {
27 public:
28 
29  virtual const char* what() const noexcept;
30 };
31 
40 {
41 public:
42 
52  Node(std::shared_ptr<Ice::Communicator> communicator) noexcept;
53 
68  template<class... T>
69  Node(int& argc, const char* argv[], T&&... iceArgs) : _ownsCommunicator(true)
70  {
71  init(argc, argv, std::forward<T>(iceArgs)...);
72  }
73 
88  template<class... T>
89  Node(int& argc, char* argv[], T&&... iceArgs) : _ownsCommunicator(true)
90  {
91  init(argc, argv, std::forward<T>(iceArgs)...);
92  }
93 
94 #ifdef _WIN32
95 
109  template<class... T>
110  Node(int& argc, const wchar_t* argv[], T&&... iceArgs) : _ownsCommunicator(true)
111  {
112  init(argc, argv, std::forward<T>(iceArgs)...);
113  }
114 
129  template<class... T>
130  Node(int& argc, wchar_t* argv[], T&&... iceArgs) : _ownsCommunicator(true)
131  {
132  init(argc, argv, std::forward<T>(iceArgs)...);
133  }
134 #endif
135 
145  template<class... T>
146  Node(T&&... iceArgs) : _ownsCommunicator(true)
147  {
148  init(Ice::initialize(std::forward<T>(iceArgs)...));
149  }
150 
156  Node(Node&& node) noexcept;
157 
162  ~Node();
163 
168  void shutdown() noexcept;
169 
175  bool isShutdown() const noexcept;
176 
180  void waitForShutdown() const noexcept;
181 
187  Node& operator=(Node&& node) noexcept;
188 
192  std::shared_ptr<Ice::Communicator> getCommunicator() const noexcept;
193 
203  std::shared_ptr<Ice::Connection> getSessionConnection(const std::string& ident) const noexcept;
204 
205 private:
206 
207  template<typename V, class... T> void init(int& argc, V argv, T&&... iceArgs)
208  {
209  auto communicator = Ice::initialize(argc, argv, std::forward<T>(iceArgs)...);
210  auto args = Ice::argsToStringSeq(argc, argv);
211  communicator->getProperties()->parseCommandLineOptions("DataStorm", args);
212  Ice::stringSeqToArgs(args, argc, argv);
213  init(communicator);
214  }
215 
216  void init(const std::shared_ptr<Ice::Communicator>&) noexcept;
217 
218  std::shared_ptr<DataStormI::Instance> _instance;
219  std::shared_ptr<DataStormI::TopicFactory> _factory;
220  bool _ownsCommunicator;
221 
222  template<typename, typename, typename> friend class Topic;
223 };
224 
225 }
#define DATASTORM_API
Definition: Config.h:37
The Topic class.
Definition: DataStorm.h:512
Node(int &argc, const char *argv[], T &&... iceArgs)
Construct a DataStorm node.
Definition: Node.h:69
The exception NodeShutdownException.
Definition: Node.h:25
Definition: CtrlCHandler.h:13
The Node class allows creating topic readers and writers.
Definition: Node.h:39
Node(int &argc, char *argv[], T &&... iceArgs)
Construct a DataStorm node.
Definition: Node.h:89
Node(T &&... iceArgs)
Construct a DataStorm node.
Definition: Node.h:146