FAST  3.2.0
Framework for Heterogeneous Medical Image Computing and Visualization
OpenIGTLinkStreamer.hpp
Go to the documentation of this file.
1 #pragma once
2 
3 //#include <boost/signals2.hpp>
4 #include <thread>
5 #include <unordered_map>
7 #include "FAST/ProcessObject.hpp"
8 #include <set>
9 #include "FASTExport.hpp"
10 
11 // Forward declare
12 
13 namespace fast {
14 
15 class Image;
16 class IGTLSocketWrapper;
17 
18 class FAST_EXPORT OpenIGTLinkStreamer : public Streamer {
20  public:
21  std::set<std::string> getImageStreamNames();
22  std::set<std::string> getTransformStreamNames();
23  std::vector<std::string> getActiveImageStreamNames();
24  std::vector<std::string> getActiveTransformStreamNames();
25  std::string getStreamDescription(std::string streamName);
26  void setConnectionAddress(std::string address);
27  void setConnectionPort(uint port);
28  uint getNrOfFrames() const;
29 
34  DataChannel::pointer getOutputPort(uint portID = 0) override;
35 
36  template<class T>
37  DataChannel::pointer getOutputPort(std::string deviceName);
38 
43  void generateStream() override;
44 
46  void loadAttributes() override;
47  private:
49 
50  // Update the streamer if any parameters have changed
51  void execute();
52 
53  uint mNrOfFrames;
54  uint mMaximumNrOfFrames;
55  bool mMaximumNrOfFramesSet;
56 
57  bool mInFreezeMode;
58 
59  std::string mAddress;
60  uint mPort;
61 
62  IGTLSocketWrapper* mSocketWrapper;
63  //igtl::ClientSocket::Pointer mSocket;
64 
65  std::set<std::string> mImageStreamNames;
66  std::set<std::string> mTransformStreamNames;
67  std::unordered_map<std::string, std::string> mStreamDescriptions;
68  std::unordered_map<std::string, uint> mOutputPortDeviceNames;
69 
70  void updateFirstFrameSetFlag();
71 };
72 
73 
74 
75 template<class T>
77  uint portID;
78  if(mOutputPortDeviceNames.count(deviceName) == 0) {
79  portID = getNrOfOutputPorts();
80  createOutputPort<T>(portID);
81  mOutputPortDeviceNames[deviceName] = portID;
82  } else {
83  portID = mOutputPortDeviceNames[deviceName];
84  }
85  return ProcessObject::getOutputPort(portID);
86 }
87 
88 
89 
90 } // end namespace
91 
fast::Streamer
Definition: Streamer.hpp:19
Streamer.hpp
fast
Definition: AffineTransformation.hpp:7
FAST_OBJECT
#define FAST_OBJECT(className)
Definition: Object.hpp:9
fast::OpenIGTLinkStreamer::getOutputPort
DataChannel::pointer getOutputPort(uint portID=0) override
fast::DataChannel::pointer
std::shared_ptr< DataChannel > pointer
Definition: DataChannel.hpp:12
fast::ProcessObject::getNrOfOutputPorts
int getNrOfOutputPorts() const
fast::ProcessObject::getOutputPort
virtual DataChannel::pointer getOutputPort(uint portID=0)
ProcessObject.hpp
uint
unsigned int uint
Definition: DataTypes.hpp:16
fast::OpenIGTLinkStreamer
Definition: OpenIGTLinkStreamer.hpp:18