MIRA
ChannelReadWrite.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012 by
3  * MetraLabs GmbH (MLAB), GERMANY
4  * and
5  * Neuroinformatics and Cognitive Robotics Labs (NICR) at TU Ilmenau, GERMANY
6  * All rights reserved.
7  *
8  * Contact: info@mira-project.org
9  *
10  * Commercial Usage:
11  * Licensees holding valid commercial licenses may use this file in
12  * accordance with the commercial license agreement provided with the
13  * software or, alternatively, in accordance with the terms contained in
14  * a written agreement between you and MLAB or NICR.
15  *
16  * GNU General Public License Usage:
17  * Alternatively, this file may be used under the terms of the GNU
18  * General Public License version 3.0 as published by the Free Software
19  * Foundation and appearing in the file LICENSE.GPL3 included in the
20  * packaging of this file. Please review the following information to
21  * ensure the GNU General Public License version 3.0 requirements will be
22  * met: http://www.gnu.org/copyleft/gpl.html.
23  * Alternatively you may (at your option) use any later version of the GNU
24  * General Public License if such license has been publicly approved by
25  * MLAB and NICR (or its successors, if any).
26  *
27  * IN NO EVENT SHALL "MLAB" OR "NICR" BE LIABLE TO ANY PARTY FOR DIRECT,
28  * INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF
29  * THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF "MLAB" OR
30  * "NICR" HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  *
32  * "MLAB" AND "NICR" SPECIFICALLY DISCLAIM ANY WARRANTIES, INCLUDING,
33  * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
34  * FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
35  * ON AN "AS IS" BASIS, AND "MLAB" AND "NICR" HAVE NO OBLIGATION TO
36  * PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS OR MODIFICATIONS.
37  */
38 
48 #ifndef _MIRA_CHANNELLOCKEDREADWRITE_H_
49 #define _MIRA_CHANNELLOCKEDREADWRITE_H_
50 
51 #ifndef Q_MOC_RUN
52 #include <boost/shared_ptr.hpp>
53 #include <boost/thread/shared_mutex.hpp>
54 #include <boost/thread/locks.hpp>
55 #endif
56 
57 #include <utils/IsCheapToCopy.h>
58 
59 #include <fw/AbstractChannel.h>
60 
61 namespace mira {
62 
64 
65 // forward declaration
66 template<typename T>
68 
69 template<typename T>
70 class Channel;
71 
72 // forward declaration
73 template <typename ConcreteChannelReadWrite>
75 
77 
85 template<typename DerivedContainer>
87 {
88 public:
93 
95 
96 
97 public:
98 
100  channel(iChannel), slot(iSlot), lock(iSlot->lock, boost::adopt_lock) {}
101 
103  // if our destructor was invoked due to stack unwinding in an exception
104  // handling mechanism, we do NOT write the data but discard it. The
105  // data is written only if the destructor is called as we got out
106  // of scope WITHOUT a raised exception.
107 #if __cplusplus >= 201703L
108  if(std::uncaught_exceptions() == 0)
109 #else
110  if(!std::uncaught_exception()) // deprecated in C++17
111 #endif
112  try {
113  DerivedContainer::finish(this); // may throw
114  }
115  // do not allow exceptions to escape from the destructor,
116  // they will terminate the program!
117  catch(std::exception& ex) {
118  MIRA_LOG_EXCEPTION(ERROR, ex) << "Error in ChannelRead/Write::finish(): ";
119  }
120  catch(...) {
121  MIRA_LOG(ERROR) << "Unknown error in ChannelRead/Write::finish()";
122  }
123  else
124  DerivedContainer::discard(this); // must not throw
125  }
126 
127 public:
128 
131 
137 
140 };
141 
150 template<typename DerivedContainer>
152 {
153 
154 public:
158 
160 
161 public:
163  channel(iChannel), slotHolder(iSlot->clone()), slot(slotHolder.get())
164  {
165  iSlot->lock.unlock_shared(); // the slot is already locked
166  // we release the lock after taking our own copy
167  }
168 
171 
172 public:
173 
175  std::unique_ptr<ChannelBufferBase::Slot> slotHolder;
176 
177  // still need this for the internal interface defined by ChannelReadWriteShared
179 
180 private:
181  // fake lock mimics locking to adhere to the expected behaviour
182  // but does not actually lock anything (since we hold an exclusive copy of the slot)
183  struct MockLock
184  {
185  bool owns_lock() { return locked; }
186  void unlock() { locked = false; };
187 
188  bool locked = true;
189  };
190 
191 public:
192  MockLock lock;
193 };
194 
196 
202 template<typename Derived>
204 {
205 public:
206 
208  typedef boost::shared_ptr<Shared> SharedPtr;
209 
210  // import some important types from our Shared class
211  typedef typename Shared::ChannelType ChannelType;
212  typedef typename Shared::ChannelTypePtr ChannelTypePtr;
213  typedef typename Shared::Slot Slot;
214  typedef typename Shared::ValueType ValueType;
215 
216 public:
217 
220 
223  shared(new Shared(channel, slot) )
224  {}
225 
226 public:
227 
238  bool isValid() const {
239  // channel must be assigned and data must be locked
240  return shared.get()!=nullptr && shared->lock.owns_lock();
241  }
242 
243 public:
244 
245  const std::string& getChannelID() {
246  static std::string emptyString;
247  return shared.get()!=nullptr ? shared->channel->getID() : emptyString;
248  }
249 
250  std::string getTypename() const {
251  return shared.get()!=nullptr ? shared->channel->getTypename() : "";
252  }
253 
255  return shared.get()!=nullptr ? shared->channel->getTypeMeta() : TypeMetaPtr();
256  }
257 
258  const Time& getTimestamp() const {
259  checkValid();
260  return shared->slot->timestamp();
261  }
262 
267  int getUseCount() const {
268  return shared.get()!=nullptr ? shared.use_count() : 0;
269  }
270 
271 public:
272 
278  uint32 getFlags() const {
279  checkValid();
280  return shared->slot->flags;
281  }
282 
288  void addFlags(uint32 moreFlags) const {
289  checkValid();
290  shared->slot->flags |= moreFlags;
291  }
292 
293 protected:
294 
296  void checkValid() const {
297  if(shared.get()==nullptr)
298  MIRA_THROW(XAccessViolation, "Trying to access ChannelRead / "
299  "ChannelWrite that was not assigned with valid data");
300 
301  if(!shared->lock.owns_lock())
302  MIRA_THROW(XAccessViolation, "Trying to access data of ChannelRead "
303  "/ ChannelWrite after losing the lock");
304  }
305 
306 protected:
307  // these read and write methods are protected by default. They will be
308  // made public in the final ChannelRead/Write classes.
309 
311  checkValid();
312  const Buffer<uint8>& res =
313  shared->channel->getBuffer()->readSerializedValue(shared->slot);
314 
315  // ??? can we ever have an empty vector here ???
316  // I think we can't, since:
317  // 1. we either have a typed buffer where we can deserialize the
318  // data, if it doesn't exist.
319  // 2. If we have an untyped buffer, someone has probably written
320  // some serialized data, otherwise the reader would never get a
321  // ChannelRead object since the channel is empty. He would have
322  // got an exception when trying to obtain the read object.
323  assert(!res.empty());
324  return res;
325  }
326 
327  const Buffer<uint8>& readSerializedValue(uint8 formatVersion, bool orLower) {
328  checkValid();
329  return shared->channel->getBuffer()->readSerializedValue(shared->slot, formatVersion, orLower);
330  }
331 
333  Buffer<uint8> readSerializedValue(std::list<BinarySerializerCodecPtr>& codecs) {
334  checkValid();
335  return shared->channel->getBuffer()->readSerializedValue(shared->slot, codecs);
336  }
337 
338  Buffer<uint8> readSerializedValue(std::list<BinarySerializerCodecPtr>& codecs,
339  uint8 formatVersion, bool orLower) {
340  checkValid();
341  return shared->channel->getBuffer()->readSerializedValue(shared->slot, codecs,
342  formatVersion, orLower);
343  }
344 
345  void readJSON(JSONValue& oValue) {
346  checkValid();
347  shared->channel->getBuffer()->readJSON(shared->slot, oValue);
348  }
349 
350  void readJSON(JSONValue& oValue, JSONSerializer& serializer) {
351  checkValid();
352  shared->channel->getBuffer()->readJSON(shared->slot, oValue, serializer);
353  }
354 
355 protected:
356 
358  checkValid();
359  shared->channel->getBuffer()->writeSerializedValue(shared->slot, std::move(data));
360  }
361 
362  void writeJSON(const JSONValue& value) {
363  checkValid();
364  shared->channel->getBuffer()->writeJSON(shared->slot, value);
365  }
366 
367  void writeJSON(JSONDeserializer& deserializer) {
368  checkValid();
369  shared->channel->getBuffer()->writeJSON(shared->slot, deserializer);
370  }
371 
372  void writeXML(const XMLDom::const_iterator& node) {
373  checkValid();
374  shared->channel->getBuffer()->writeXML(shared->slot, node);
375  }
376 
377 protected:
379 };
380 
381 
382 
383 template<typename Derived, typename T>
385 {
386 public:
387 
389 
390  // push down some important types from our base
391  typedef typename Base::Shared Shared;
393  typedef typename Base::Slot Slot;
394  typedef typename Base::ValueType ValueType;
395 
396 public:
397 
400 
403 
404 protected:
405 
412  this->checkValid();
413  return static_cast<Slot*>(this->shared->slot)->data;
414  }
415 
421  const ValueType& internalValue() const {
422  this->checkValid();
423  return static_cast<Slot*>(this->shared->slot)->data;
424  }
425 
426 };
427 
428 
433 template<typename Derived>
434 class ChannelReadWriteBase<Derived, void> : public ChannelReadWriteCommonBase<Derived>
435 {
436 public:
437 
439 
440  // push down some important types from our base
441  typedef typename Base::Shared Shared;
443  typedef typename Base::ValueType ValueType;
444 
445 public:
446 
449 
452 
453 protected:
454 
461  this->checkValid();
462  return this->shared->channel->getBuffer()->getStampedHeader(this->shared->slot);
463  }
464 
470  const ValueType& internalValue() const {
471  this->checkValid();
472  return this->shared->channel->getBuffer()->getStampedHeader(this->shared->slot);
473  }
474 
475 };
476 
478 
493 template<typename T>
494 class ChannelRead : public ChannelReadWriteBase<ChannelRead<T>,T>
495 {
496 protected:
497 
499 
500  // push down some important types from our base
501  typedef typename Base::Shared Shared;
503  typedef typename Base::ValueType ValueType;
504 
505 public:
506 
517 
523  ChannelRead(ChannelTypePtr channel, ChannelBufferBase::Slot* slot) : Base(channel, slot) {}
524 
525 public:
526 
533  operator const ValueType&() const { return this->internalValue(); }
534 
542  const ValueType& operator*() const { return this->internalValue(); }
543 
563  const ValueType* operator->() const { return &this->internalValue(); }
564 
565 public:
566  // make read-methods public
567 
569  return Base::readSerializedValue();
570  }
571 
572  const Buffer<uint8>& readSerializedValue(uint8 formatVersion, bool orLower) {
573  return Base::readSerializedValue(formatVersion, orLower);
574  }
575 
576  Buffer<uint8> readSerializedValue(std::list<BinarySerializerCodecPtr>& codecs) {
577  return Base::readSerializedValue(codecs);
578  }
579 
580  Buffer<uint8> readSerializedValue(std::list<BinarySerializerCodecPtr>& codecs,
581  uint8 formatVersion, bool orLower) {
582  return Base::readSerializedValue(codecs, formatVersion, orLower);
583  }
584 
585 
586  void readJSON(JSONValue& oValue) {
587  Base::readJSON(oValue);
588  }
589 
590  void readJSON(JSONValue& oValue, JSONSerializer& serializer) {
591  Base::readJSON(oValue, serializer);
592  }
593 
594 public:
595 
601  void finish() {
602  if(this->isValid())
603  finish(this->shared.get());
604  }
605 
606 public:
607 
612 
613 protected:
614 
616 
617  // API for ~ChannelReadWriteShared
618  static void finish(Shared* shared) {
619  assert(shared!=nullptr);
620  if(shared->lock.owns_lock())
621  shared->lock.unlock();
622  }
623 
624  static void discard(Shared* shared) {
625  // for read objects a "discard" is equal to a "finish"
626  finish(shared);
627  }
628 
629 };
630 
632 
651 template<typename T>
652 class ChannelWrite : public ChannelReadWriteBase<ChannelWrite<T>, T>
653 {
654 protected:
656 
657  // push down some important types from our base
658  typedef typename Base::Shared Shared;
660  typedef typename Base::ValueType ValueType;
661 
662 
663 public:
664 
675 
682  ChannelWrite(ChannelTypePtr channel, ChannelBufferBase::Slot* slot) : Base(channel, slot) {
683  static_cast<StampedHeader&>(this->internalValue()).timestamp = Time::now();
684  }
685 
686 public:
687 
694  operator ValueType&() { return this->internalValue(); }
695 
703  ValueType& operator*() { return this->internalValue(); }
704 
705 
706  /*const ValueType& operator=(const T& value) {
707  this->internalValue() = value;
708  return this->internalValue();
709  }*/
710 
711  const ValueType& operator=(const ValueType& value) {
712  this->internalValue() = value;
713  return this->internalValue();
714  }
715 
716 
736  ValueType* operator->() { return &this->internalValue(); }
737 
738 public:
739  // make write-methods public
740 
742  Base::writeSerializedValue(std::move(data));
743  }
744 
745  void writeJSON(const JSONValue& value) {
746  Base::writeJSON(value);
747  }
748 
749  void writeJSON(JSONDeserializer& deserializer) {
750  Base::writeJSON(deserializer);
751  }
752 
753  void writeXML(const XMLDom::const_iterator& node) {
754  Base::writeXML(node);
755  }
756 
757 public:
758 
765  void finish()
766  {
767  if(this->isValid())
768  finish(this->shared.get());
769  }
770 
779  void discard()
780  {
781  if(this->isValid())
782  discard(this->shared.get());
783  }
784 
785 
786 public:
787 
792 
793 protected:
795 
796  // API for ~ChannelReadWriteShared
797  static void finish(Shared* shared)
798  {
799  assert(shared!=nullptr);
800  if(shared->lock.owns_lock()) {
801  // release lock object, since it is unlocked by finishWrite()
802  shared->lock.release();
803  // inform the channel, that the writing was finished
804  shared->channel->finishWrite(shared->slot);
805  }
806  }
807 
808  static void discard(Shared* shared)
809  {
810  assert(shared!=nullptr);
811  if(shared->lock.owns_lock()) {
812  // release lock object, since it is unlocked by discardWrite()
813  shared->lock.release();
814  // inform the channel, to discard writing
815  shared->channel->discardWrite(shared->slot);
816  }
817  }
818 };
819 
821 
822 template <typename Derived, typename T, bool Copy = IsCheapToCopy<T>::value>
824 {
826 };
827 
828 template <typename Derived, typename T>
829 struct ChannelReadSelectCopy<Derived, T, true>
830 {
832 };
833 
835 
836 // typed read and writes
837 
838 template<typename T>
840 {
844  typedef boost::shared_lock<boost::shared_mutex> Lock; // use shared locks for readers
846 };
847 
848 template<typename T>
850 {
854  typedef boost::unique_lock<boost::shared_mutex> Lock; // use unique locks for writers
856 };
857 
859 // untyped read and writes
860 
861 template<>
863 {
867  typedef boost::shared_lock<boost::shared_mutex> Lock; // use shared locks for readers
869 };
870 
871 template<>
873 {
877  typedef boost::unique_lock<boost::shared_mutex> Lock; // use unique locks for writers
879 };
880 
882 
883 }
884 
885 
886 #endif
ChannelReadWriteShared(ChannelTypePtr iChannel, ChannelBufferBase::Slot *iSlot)
Definition: ChannelReadWrite.h:99
static void finish(Shared *shared)
Definition: ChannelReadWrite.h:618
Serializer for serializing objects in JSON format.
Definition: JSONSerializer.h:93
AbstractChannel ChannelType
Definition: ChannelReadWrite.h:864
boost::shared_mutex lock
Definition: ChannelBuffer.h:168
Base::Shared Shared
Definition: ChannelReadWrite.h:391
Base::ValueType ValueType
Definition: ChannelReadWrite.h:394
ChannelReadWriteBase()
Constructs an empty (invalid) ChannelReadWriteBase object.
Definition: ChannelReadWrite.h:399
Base::ChannelTypePtr ChannelTypePtr
Definition: ChannelReadWrite.h:442
Base::Shared Shared
Definition: ChannelReadWrite.h:441
void finish()
Releases the lock explicitly.
Definition: ChannelReadWrite.h:601
boost::shared_lock< boost::shared_mutex > Lock
Definition: ChannelReadWrite.h:844
~ChannelReadWriteShared()
Definition: ChannelReadWrite.h:102
ChannelReadWriteShared< ChannelWrite< T > > Shared
Definition: ChannelReadWrite.h:855
void discard()
Releases the lock explicitly WITHOUT informing the Channel and without signaling the subscribers...
Definition: ChannelReadWrite.h:779
Definition: SyncTimedRead.h:62
An exception that occurs whenever a channel has no data.
Definition: Channel.h:88
const Buffer< uint8 > & readSerializedValue(uint8 formatVersion, bool orLower)
Definition: ChannelReadWrite.h:327
void readJSON(JSONValue &oValue)
Definition: ChannelReadWrite.h:345
ChannelRead(ChannelTypePtr channel, ChannelBufferBase::Slot *slot)
Is called by Channel to construct a ChannelRead object.
Definition: ChannelReadWrite.h:523
ChannelReadWriteCommonBase< Derived > Base
Definition: ChannelReadWrite.h:438
ChannelBuffer< T >::ValueType ValueType
Definition: ChannelReadWrite.h:853
ChannelBuffer< void >::Slot SlotType
Definition: ChannelReadWrite.h:865
ChannelBufferBase::Slot * slot
the slot in that channel we are pointing on (this pointer is valid unless the channel&#39;s buffer is des...
Definition: ChannelReadWrite.h:136
ChannelWrite(ChannelTypePtr channel, ChannelBufferBase::Slot *slot)
Is called by Channel to construct a valid ChannelWrite object with the corresponding data...
Definition: ChannelReadWrite.h:682
uint32 getFlags() const
For internal use only.
Definition: ChannelReadWrite.h:278
specialize cv::DataType for our ImgPixel and inherit from cv::DataType<Vec>
Definition: IOService.h:67
Shared::ChannelType ChannelType
Definition: ChannelReadWrite.h:211
Base::ChannelTypePtr ChannelTypePtr
Definition: ChannelReadWrite.h:659
static void discard(Shared *shared)
Definition: ChannelReadWrite.h:624
const ValueType & internalValue() const
Returns a const reference on the data.
Definition: ChannelReadWrite.h:470
ChannelTypePtr channel
pointer to the channel our data/slot belongs to
Definition: ChannelReadWrite.h:170
An object that allows exclusive write access to data of a channel.
Definition: ChannelReadWrite.h:652
const ValueType & operator=(const ValueType &value)
Definition: ChannelReadWrite.h:711
#define MIRA_LOG(level)
Use this macro to log data.
Definition: LoggingCore.h:529
Base::ChannelTypePtr ChannelTypePtr
Definition: ChannelReadWrite.h:502
ChannelBuffer< T >::Slot SlotType
Definition: ChannelReadWrite.h:852
ChannelBuffer< T >::Slot SlotType
Definition: ChannelReadWrite.h:842
ChannelBuffer< T >::ValueType ValueType
Definition: ChannelReadWrite.h:843
Base::Shared Shared
Definition: ChannelReadWrite.h:501
ChannelReadWriteCommonBase(ChannelTypePtr channel, ChannelBufferBase::Slot *slot)
Constructs a valid ChannelReadWriteBase object that is assigned to a channel and slot.
Definition: ChannelReadWrite.h:222
AbstractChannel ChannelType
Definition: ChannelReadWrite.h:874
ChannelBuffer< void >::Slot SlotType
Definition: ChannelReadWrite.h:875
void addFlags(uint32 moreFlags) const
For internal use only.
Definition: ChannelReadWrite.h:288
boost::unique_lock< boost::shared_mutex > Lock
Definition: ChannelReadWrite.h:854
void writeSerializedValue(Buffer< uint8 > data)
Definition: ChannelReadWrite.h:741
A special base class creating and keeping a copy of the channel slot instead of managing access and l...
Definition: ChannelReadWrite.h:151
Definition: ChannelReadWrite.h:67
ChannelReadWriteBase()
Constructs an empty (invalid) ChannelReadWriteBase object.
Definition: ChannelReadWrite.h:448
void writeJSON(JSONDeserializer &deserializer)
Definition: ChannelReadWrite.h:749
An object that allows read access to data of a channel.
Definition: ChannelReadWrite.h:494
void readJSON(JSONValue &oValue, JSONSerializer &serializer)
Definition: ChannelReadWrite.h:350
#define MIRA_THROW(ex, msg)
Macro for throwing an exception.
Definition: Exception.h:82
Internally used by ChannelReadWriteBase! It contains the information about the channel and slot that ...
Definition: ChannelReadWrite.h:86
void finish()
Releases the lock explicitly and informs the Channel to signal all Subscribers that new data is avail...
Definition: ChannelReadWrite.h:765
Base::Shared Shared
Definition: ChannelReadWrite.h:658
void writeJSON(const JSONValue &value)
Definition: ChannelReadWrite.h:362
ChannelBuffer< void >::ValueType ValueType
Definition: ChannelReadWrite.h:876
const ValueType & internalValue() const
Returns a const reference on the data.
Definition: ChannelReadWrite.h:421
ChannelReadWriteTraits< DerivedContainer >::SlotType Slot
Definition: ChannelReadWrite.h:156
Const sibling_iterator for iterating over xml nodes that have the same parent (siblings) ...
Definition: XMLDom.h:671
Base::Slot Slot
Definition: ChannelReadWrite.h:393
Wrapper class for boost::posix_time::ptime for adding more functionality to it.
Definition: Time.h:418
ChannelReadWriteCommonBase< Derived > Base
Definition: ChannelReadWrite.h:388
std::unique_ptr< ChannelBufferBase::Slot > slotHolder
we are the unique owner of this slot copy
Definition: ChannelReadWrite.h:175
const Buffer< uint8 > & readSerializedValue()
Definition: ChannelReadWrite.h:568
ValueType * operator->()
Returns a pointer on the data.
Definition: ChannelReadWrite.h:736
ValueType & internalValue()
Returns a reference on the data.
Definition: ChannelReadWrite.h:460
bool isValid() const
Returns true, if data was assigned to the ChannelRead or ChannelWrite and if this data is locked...
Definition: ChannelReadWrite.h:238
Definition: ChannelReadWrite.h:74
boost::shared_ptr< Shared > SharedPtr
Definition: ChannelReadWrite.h:208
ChannelWrite()
Default constructor that constructs a ChannelWrite object that is invalid at the beginning and contai...
Definition: ChannelReadWrite.h:674
Deserializer for serializing objects from JSON format.
Definition: JSONSerializer.h:400
ChannelReadWriteTraits< DerivedContainer >::Lock Lock
Definition: ChannelReadWrite.h:90
void writeJSON(JSONDeserializer &deserializer)
Definition: ChannelReadWrite.h:367
void writeXML(const XMLDom::const_iterator &node)
Definition: ChannelReadWrite.h:372
Shared::Slot Slot
Definition: ChannelReadWrite.h:213
Definition: AbstractChannel.h:70
The common header for all stamped data.
Definition: Stamped.h:62
const ValueType & operator*() const
Returns a const reference on the data.
Definition: ChannelReadWrite.h:542
ChannelRead()
Default constructor that constructs a ChannelRead object that is invalid at the beginning and contain...
Definition: ChannelReadWrite.h:516
ChannelReadWriteBase< ChannelWrite< T >, T > Base
Definition: ChannelReadWrite.h:655
bool empty() const
Checks if the buffer is empty (used size == 0).
Definition: Buffer.h:303
ValueType & operator*()
Returns a reference on the data.
Definition: ChannelReadWrite.h:703
TypeMetaPtr getTypeMeta() const
Definition: ChannelReadWrite.h:254
ChannelReadWriteTraits< DerivedContainer >::ChannelType ChannelType
Definition: ChannelReadWrite.h:155
Type trait to define if a class is cheap to copy.
int getUseCount() const
Returns the number of shared instances for this data, may be useful for debugging purposes...
Definition: ChannelReadWrite.h:267
void writeXML(const XMLDom::const_iterator &node)
Definition: ChannelReadWrite.h:753
ChannelReadWriteBase< ChannelRead< T >, T > Base
Definition: ChannelReadWrite.h:498
ChannelType * ChannelTypePtr
Definition: ChannelReadWrite.h:159
const std::string & getChannelID()
Definition: ChannelReadWrite.h:245
Mix in for adding a time stamp, an optional frame id and an optional sequence id to data types like P...
Definition: Stamped.h:149
Shared::ChannelTypePtr ChannelTypePtr
Definition: ChannelReadWrite.h:212
boost::shared_ptr< TypeMeta > TypeMetaPtr
Definition: MetaSerializer.h:309
ChannelBufferBase::Slot * slot
Definition: ChannelReadWrite.h:178
Definition: ChannelReadWrite.h:203
Buffer< uint8 > readSerializedValue(std::list< BinarySerializerCodecPtr > &codecs, uint8 formatVersion, bool orLower)
Definition: ChannelReadWrite.h:338
const Buffer< uint8 > & readSerializedValue()
Definition: ChannelReadWrite.h:310
ChannelReadWriteTraits< DerivedContainer >::ValueType ValueType
Definition: ChannelReadWrite.h:157
void writeSerializedValue(Buffer< uint8 > data)
Definition: ChannelReadWrite.h:357
ChannelType * ChannelTypePtr
Definition: ChannelReadWrite.h:94
ChannelReadWriteTraits< DerivedContainer >::SlotType Slot
Definition: ChannelReadWrite.h:91
void checkValid() const
checks if we are still locked, if not it throws a XAccessViolation
Definition: ChannelReadWrite.h:296
ConcreteChannel< T > ChannelType
Definition: ChannelReadWrite.h:851
Container for storing a single data element in the linked list.
Definition: ChannelBuffer.h:166
Lock lock
a shared lock for that data in the channel&#39;s buffer
Definition: ChannelReadWrite.h:139
ChannelReadCopy(ChannelTypePtr iChannel, ChannelBufferBase::Slot *iSlot)
Definition: ChannelReadWrite.h:162
const ValueType * operator->() const
Returns a const pointer on the data.
Definition: ChannelReadWrite.h:563
ChannelReadCopy< Derived > Shared
Definition: ChannelReadWrite.h:831
static void discard(Shared *shared)
Definition: ChannelReadWrite.h:808
#define MIRA_LOG_EXCEPTION(level, ex)
Log the specified exception, including all information that the exception object carries.
Definition: LoggingAux.h:107
Channel< T > getChannel()
Returns a read-only channel proxy object of the underlying channel.
ChannelReadWriteCommonBase()
Constructs an empty (invalid) ChannelReadWriteBase object.
Definition: ChannelReadWrite.h:219
std::string getTypename() const
Definition: ChannelReadWrite.h:250
ChannelTypePtr channel
pointer to the channel our data/slot belongs to
Definition: ChannelReadWrite.h:130
static Time now() static Time eternity()
Returns the current utc based time.
Definition: Time.h:481
ChannelReadWriteShared< ChannelWrite< void > > Shared
Definition: ChannelReadWrite.h:878
ConcreteChannel< T > ChannelType
Definition: ChannelReadWrite.h:841
Base::ValueType ValueType
Definition: ChannelReadWrite.h:443
boost::shared_lock< boost::shared_mutex > Lock
Definition: ChannelReadWrite.h:867
void readJSON(JSONValue &oValue)
Definition: ChannelReadWrite.h:586
Shared::ValueType ValueType
Definition: ChannelReadWrite.h:214
SharedPtr shared
Definition: ChannelReadWrite.h:378
Base::ValueType ValueType
Definition: ChannelReadWrite.h:503
boost::unique_lock< boost::shared_mutex > Lock
Definition: ChannelReadWrite.h:877
void writeJSON(const JSONValue &value)
Definition: ChannelReadWrite.h:745
Definition: ChannelReadWrite.h:823
ValueType & internalValue()
Returns a reference on the data.
Definition: ChannelReadWrite.h:411
Buffer< uint8 > readSerializedValue(std::list< BinarySerializerCodecPtr > &codecs)
Definition: ChannelReadWrite.h:576
ChannelReadWriteBase(ChannelTypePtr channel, ChannelBufferBase::Slot *slot)
Constructs a valid ChannelReadWriteBase object that is assigned to a channel and slot.
Definition: ChannelReadWrite.h:402
void readJSON(JSONValue &oValue, JSONSerializer &serializer)
Definition: ChannelReadWrite.h:590
Base::ChannelTypePtr ChannelTypePtr
Definition: ChannelReadWrite.h:392
ChannelBuffer< void >::ValueType ValueType
Definition: ChannelReadWrite.h:866
ChannelReadWriteShared< ChannelRead< void > > Shared
Definition: ChannelReadWrite.h:868
Definition: LoggingCore.h:75
json::Value JSONValue
Imports the json::Value type into mira namespace.
Definition: JSON.h:363
Base class for all framework channels.
ChannelReadWriteTraits< DerivedContainer >::ValueType ValueType
Definition: ChannelReadWrite.h:92
Definition: ChannelReadWrite.h:384
ChannelReadWriteBase(ChannelTypePtr channel, ChannelBufferBase::Slot *slot)
Constructs a valid ChannelReadWriteBase object that is assigned to a channel and slot.
Definition: ChannelReadWrite.h:451
Base::ValueType ValueType
Definition: ChannelReadWrite.h:660
Buffer< uint8 > readSerializedValue(std::list< BinarySerializerCodecPtr > &codecs, uint8 formatVersion, bool orLower)
Definition: ChannelReadWrite.h:580
MockLock lock
Definition: ChannelReadWrite.h:192
Channel< T > getChannel()
Returns a write-only channel proxy object of the underlying channel.
ChannelReadWriteShared< Derived > Shared
Definition: ChannelReadWrite.h:825
Buffer< uint8 > readSerializedValue(std::list< BinarySerializerCodecPtr > &codecs)
Same as above, but allows to specify codecs for serialization.
Definition: ChannelReadWrite.h:333
ChannelReadWriteTraits< Derived >::Shared Shared
Definition: ChannelReadWrite.h:207
ChannelReadSelectCopy< ChannelRead< T >, T >::Shared Shared
Definition: ChannelReadWrite.h:845
const Time & getTimestamp() const
Definition: ChannelReadWrite.h:258
static void finish(Shared *shared)
Definition: ChannelReadWrite.h:797
ChannelReadWriteTraits< DerivedContainer >::ChannelType ChannelType
Definition: ChannelReadWrite.h:89
const Buffer< uint8 > & readSerializedValue(uint8 formatVersion, bool orLower)
Definition: ChannelReadWrite.h:572