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)
164  {
165  // it should not be possible to get a wrong type in here
166  // without a rework of the channel read mechanism,
167  // so we only do a thorough check in debug build
168  assert(dynamic_cast<Slot*>(iSlot) != nullptr);
169 
170  auto typedSlot = static_cast<Slot*>(iSlot);
171 
172  slotHolder = typedSlot->clone();
173  slot = slotHolder.get();
174  iSlot->lock.unlock_shared(); // the slot is already locked
175  // we release the lock after taking our own copy
176  }
177 
180 
181 public:
182 
184  std::unique_ptr<Slot> slotHolder;
185 
186  // still need this for the internal interface defined by ChannelReadWriteShared
188 
189 private:
190  // fake lock mimics locking to adhere to the expected behaviour
191  // but does not actually lock anything (since we hold an exclusive copy of the slot)
192  struct MockLock
193  {
194  bool owns_lock() { return locked; }
195  void unlock() { locked = false; };
196 
197  bool locked = true;
198  };
199 
200 public:
201  MockLock lock;
202 };
203 
205 
211 template<typename Derived>
213 {
214 public:
215 
217  typedef boost::shared_ptr<Shared> SharedPtr;
218 
219  // import some important types from our Shared class
220  typedef typename Shared::ChannelType ChannelType;
221  typedef typename Shared::ChannelTypePtr ChannelTypePtr;
222  typedef typename Shared::Slot Slot;
223  typedef typename Shared::ValueType ValueType;
224 
225 public:
226 
229 
232  shared(new Shared(channel, slot) )
233  {}
234 
235 public:
236 
247  bool isValid() const {
248  // channel must be assigned and data must be locked
249  return shared.get()!=nullptr && shared->lock.owns_lock();
250  }
251 
252 public:
253 
254  const std::string& getChannelID() {
255  static std::string emptyString;
256  return shared.get()!=nullptr ? shared->channel->getID() : emptyString;
257  }
258 
259  std::string getTypename() const {
260  return shared.get()!=nullptr ? shared->channel->getTypename() : "";
261  }
262 
264  return shared.get()!=nullptr ? shared->channel->getTypeMeta() : TypeMetaPtr();
265  }
266 
267  const Time& getTimestamp() const {
268  checkValid();
269  return shared->slot->timestamp();
270  }
271 
276  int getUseCount() const {
277  return shared.get()!=nullptr ? shared.use_count() : 0;
278  }
279 
280 public:
281 
287  uint32 getFlags() const {
288  checkValid();
289  return shared->slot->flags;
290  }
291 
297  void addFlags(uint32 moreFlags) const {
298  checkValid();
299  shared->slot->flags |= moreFlags;
300  }
301 
302 protected:
303 
305  void checkValid() const {
306  if(shared.get()==nullptr)
307  MIRA_THROW(XAccessViolation, "Trying to access ChannelRead / "
308  "ChannelWrite that was not assigned with valid data");
309 
310  if(!shared->lock.owns_lock())
311  MIRA_THROW(XAccessViolation, "Trying to access data of ChannelRead "
312  "/ ChannelWrite after losing the lock");
313  }
314 
315 protected:
316  // these read and write methods are protected by default. They will be
317  // made public in the final ChannelRead/Write classes.
318 
320  checkValid();
321  const Buffer<uint8>& res =
322  shared->channel->getBuffer()->readSerializedValue(shared->slot);
323 
324  // ??? can we ever have an empty vector here ???
325  // I think we can't, since:
326  // 1. we either have a typed buffer where we can deserialize the
327  // data, if it doesn't exist.
328  // 2. If we have an untyped buffer, someone has probably written
329  // some serialized data, otherwise the reader would never get a
330  // ChannelRead object since the channel is empty. He would have
331  // got an exception when trying to obtain the read object.
332  assert(!res.empty());
333  return res;
334  }
335 
336  const Buffer<uint8>& readSerializedValue(uint8 formatVersion, bool orLower) {
337  checkValid();
338  return shared->channel->getBuffer()->readSerializedValue(shared->slot, formatVersion, orLower);
339  }
340 
342  Buffer<uint8> readSerializedValue(std::list<BinarySerializerCodecPtr>& codecs) {
343  checkValid();
344  return shared->channel->getBuffer()->readSerializedValue(shared->slot, codecs);
345  }
346 
347  Buffer<uint8> readSerializedValue(std::list<BinarySerializerCodecPtr>& codecs,
348  uint8 formatVersion, bool orLower) {
349  checkValid();
350  return shared->channel->getBuffer()->readSerializedValue(shared->slot, codecs,
351  formatVersion, orLower);
352  }
353 
354  void readJSON(JSONValue& oValue) {
355  checkValid();
356  shared->channel->getBuffer()->readJSON(shared->slot, oValue);
357  }
358 
359  void readJSON(JSONValue& oValue, JSONSerializer& serializer) {
360  checkValid();
361  shared->channel->getBuffer()->readJSON(shared->slot, oValue, serializer);
362  }
363 
364 protected:
365 
367  checkValid();
368  shared->channel->getBuffer()->writeSerializedValue(shared->slot, std::move(data));
369  }
370 
371  void writeJSON(const JSONValue& value) {
372  checkValid();
373  shared->channel->getBuffer()->writeJSON(shared->slot, value);
374  }
375 
376  void writeJSON(JSONDeserializer& deserializer) {
377  checkValid();
378  shared->channel->getBuffer()->writeJSON(shared->slot, deserializer);
379  }
380 
381  void writeXML(const XMLDom::const_iterator& node) {
382  checkValid();
383  shared->channel->getBuffer()->writeXML(shared->slot, node);
384  }
385 
386 protected:
388 };
389 
390 
391 
392 template<typename Derived, typename T>
394 {
395 public:
396 
398 
399  // push down some important types from our base
400  typedef typename Base::Shared Shared;
402  typedef typename Base::Slot Slot;
403  typedef typename Base::ValueType ValueType;
404 
405 public:
406 
409 
412 
413 protected:
414 
421  this->checkValid();
422  return static_cast<Slot*>(this->shared->slot)->data;
423  }
424 
430  const ValueType& internalValue() const {
431  this->checkValid();
432  return static_cast<Slot*>(this->shared->slot)->data;
433  }
434 
435 };
436 
437 
442 template<typename Derived>
443 class ChannelReadWriteBase<Derived, void> : public ChannelReadWriteCommonBase<Derived>
444 {
445 public:
446 
448 
449  // push down some important types from our base
450  typedef typename Base::Shared Shared;
452  typedef typename Base::ValueType ValueType;
453 
454 public:
455 
458 
461 
462 protected:
463 
470  this->checkValid();
471  return this->shared->channel->getBuffer()->getStampedHeader(this->shared->slot);
472  }
473 
479  const ValueType& internalValue() const {
480  this->checkValid();
481  return this->shared->channel->getBuffer()->getStampedHeader(this->shared->slot);
482  }
483 
484 };
485 
487 
502 template<typename T>
503 class ChannelRead : public ChannelReadWriteBase<ChannelRead<T>,T>
504 {
505 protected:
506 
508 
509  // push down some important types from our base
510  typedef typename Base::Shared Shared;
512  typedef typename Base::ValueType ValueType;
513 
514 public:
515 
526 
532  ChannelRead(ChannelTypePtr channel, ChannelBufferBase::Slot* slot) : Base(channel, slot) {}
533 
534 public:
535 
542  operator const ValueType&() const { return this->internalValue(); }
543 
551  const ValueType& operator*() const { return this->internalValue(); }
552 
572  const ValueType* operator->() const { return &this->internalValue(); }
573 
574 public:
575  // make read-methods public
576 
578  return Base::readSerializedValue();
579  }
580 
581  const Buffer<uint8>& readSerializedValue(uint8 formatVersion, bool orLower) {
582  return Base::readSerializedValue(formatVersion, orLower);
583  }
584 
585  Buffer<uint8> readSerializedValue(std::list<BinarySerializerCodecPtr>& codecs) {
586  return Base::readSerializedValue(codecs);
587  }
588 
589  Buffer<uint8> readSerializedValue(std::list<BinarySerializerCodecPtr>& codecs,
590  uint8 formatVersion, bool orLower) {
591  return Base::readSerializedValue(codecs, formatVersion, orLower);
592  }
593 
594 
595  void readJSON(JSONValue& oValue) {
596  Base::readJSON(oValue);
597  }
598 
599  void readJSON(JSONValue& oValue, JSONSerializer& serializer) {
600  Base::readJSON(oValue, serializer);
601  }
602 
603 public:
604 
610  void finish() {
611  if(this->isValid())
612  finish(this->shared.get());
613  }
614 
615 public:
616 
621 
622 protected:
623 
625 
626  // API for ~ChannelReadWriteShared
627  static void finish(Shared* shared) {
628  assert(shared!=nullptr);
629  if(shared->lock.owns_lock())
630  shared->lock.unlock();
631  }
632 
633  static void discard(Shared* shared) {
634  // for read objects a "discard" is equal to a "finish"
635  finish(shared);
636  }
637 
638 };
639 
641 
660 template<typename T>
661 class ChannelWrite : public ChannelReadWriteBase<ChannelWrite<T>, T>
662 {
663 protected:
665 
666  // push down some important types from our base
667  typedef typename Base::Shared Shared;
669  typedef typename Base::ValueType ValueType;
670 
671 
672 public:
673 
684 
693  ChannelWrite(ChannelTypePtr channel, ChannelBufferBase::Slot* slot) : Base(channel, slot) {
694  static_cast<StampedHeader&>(this->internalValue()).timestamp = Time::now();
695  }
696 
697 public:
698 
705  operator ValueType&() { return this->internalValue(); }
706 
714  ValueType& operator*() { return this->internalValue(); }
715 
716 
717  /*const ValueType& operator=(const T& value) {
718  this->internalValue() = value;
719  return this->internalValue();
720  }*/
721 
722  const ValueType& operator=(const ValueType& value) {
723  this->internalValue() = value;
724  return this->internalValue();
725  }
726 
727 
747  ValueType* operator->() { return &this->internalValue(); }
748 
749 public:
750  // make write-methods public
751 
753  Base::writeSerializedValue(std::move(data));
754  }
755 
756  void writeJSON(const JSONValue& value) {
757  Base::writeJSON(value);
758  }
759 
760  void writeJSON(JSONDeserializer& deserializer) {
761  Base::writeJSON(deserializer);
762  }
763 
764  void writeXML(const XMLDom::const_iterator& node) {
765  Base::writeXML(node);
766  }
767 
768 public:
769 
776  void finish()
777  {
778  if(this->isValid())
779  finish(this->shared.get());
780  }
781 
790  void discard()
791  {
792  if(this->isValid())
793  discard(this->shared.get());
794  }
795 
796 
797 public:
798 
803 
804 protected:
806 
807  // API for ~ChannelReadWriteShared
808  static void finish(Shared* shared)
809  {
810  assert(shared!=nullptr);
811  if(shared->lock.owns_lock()) {
812  // release lock object, since it is unlocked by finishWrite()
813  shared->lock.release();
814  // inform the channel, that the writing was finished
815  shared->channel->finishWrite(shared->slot);
816  }
817  }
818 
819  static void discard(Shared* shared)
820  {
821  assert(shared!=nullptr);
822  if(shared->lock.owns_lock()) {
823  // release lock object, since it is unlocked by discardWrite()
824  shared->lock.release();
825  // inform the channel, to discard writing
826  shared->channel->discardWrite(shared->slot);
827  }
828  }
829 };
830 
832 
833 template <typename Derived, typename T, bool Copy = IsCheapToCopy<T>::value>
835 {
837 };
838 
839 template <typename Derived, typename T>
840 struct ChannelReadSelectCopy<Derived, T, true>
841 {
843 };
844 
846 
847 // typed read and writes
848 
849 template<typename T>
851 {
855  typedef boost::shared_lock<boost::shared_mutex> Lock; // use shared locks for readers
857 };
858 
859 template<typename T>
861 {
865  typedef boost::unique_lock<boost::shared_mutex> Lock; // use unique locks for writers
867 };
868 
870 // untyped read and writes
871 
872 template<>
874 {
878  typedef boost::shared_lock<boost::shared_mutex> Lock; // use shared locks for readers
880 };
881 
882 template<>
884 {
888  typedef boost::unique_lock<boost::shared_mutex> Lock; // use unique locks for writers
890 };
891 
893 
894 }
895 
896 
897 #endif
ChannelReadWriteShared(ChannelTypePtr iChannel, ChannelBufferBase::Slot *iSlot)
Definition: ChannelReadWrite.h:99
static void finish(Shared *shared)
Definition: ChannelReadWrite.h:627
Serializer for serializing objects in JSON format.
Definition: JSONSerializer.h:95
AbstractChannel ChannelType
Definition: ChannelReadWrite.h:875
boost::shared_mutex lock
Definition: ChannelBuffer.h:166
Base::Shared Shared
Definition: ChannelReadWrite.h:400
Base::ValueType ValueType
Definition: ChannelReadWrite.h:403
ChannelReadWriteBase()
Constructs an empty (invalid) ChannelReadWriteBase object.
Definition: ChannelReadWrite.h:408
Base::ChannelTypePtr ChannelTypePtr
Definition: ChannelReadWrite.h:451
Base::Shared Shared
Definition: ChannelReadWrite.h:450
void finish()
Releases the lock explicitly.
Definition: ChannelReadWrite.h:610
boost::shared_lock< boost::shared_mutex > Lock
Definition: ChannelReadWrite.h:855
~ChannelReadWriteShared()
Definition: ChannelReadWrite.h:102
ChannelReadWriteShared< ChannelWrite< T > > Shared
Definition: ChannelReadWrite.h:866
void discard()
Releases the lock explicitly WITHOUT informing the Channel and without signaling the subscribers...
Definition: ChannelReadWrite.h:790
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:336
void readJSON(JSONValue &oValue)
Definition: ChannelReadWrite.h:354
ChannelRead(ChannelTypePtr channel, ChannelBufferBase::Slot *slot)
Is called by Channel to construct a ChannelRead object.
Definition: ChannelReadWrite.h:532
ChannelReadWriteCommonBase< Derived > Base
Definition: ChannelReadWrite.h:447
ChannelBuffer< T >::ValueType ValueType
Definition: ChannelReadWrite.h:864
ChannelBuffer< void >::Slot SlotType
Definition: ChannelReadWrite.h:876
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:693
uint32 getFlags() const
For internal use only.
Definition: ChannelReadWrite.h:287
specialize cv::DataType for our ImgPixel and inherit from cv::DataType<Vec>
Definition: IOService.h:67
Shared::ChannelType ChannelType
Definition: ChannelReadWrite.h:220
Base::ChannelTypePtr ChannelTypePtr
Definition: ChannelReadWrite.h:668
static void discard(Shared *shared)
Definition: ChannelReadWrite.h:633
const ValueType & internalValue() const
Returns a const reference on the data.
Definition: ChannelReadWrite.h:479
ChannelTypePtr channel
pointer to the channel our data/slot belongs to
Definition: ChannelReadWrite.h:179
An object that allows exclusive write access to data of a channel.
Definition: ChannelReadWrite.h:661
const ValueType & operator=(const ValueType &value)
Definition: ChannelReadWrite.h:722
#define MIRA_LOG(level)
Use this macro to log data.
Definition: LoggingCore.h:529
Base::ChannelTypePtr ChannelTypePtr
Definition: ChannelReadWrite.h:511
std::unique_ptr< Slot > slotHolder
we are the unique owner of this slot copy
Definition: ChannelReadWrite.h:184
ChannelBuffer< T >::Slot SlotType
Definition: ChannelReadWrite.h:863
ChannelBuffer< T >::Slot SlotType
Definition: ChannelReadWrite.h:853
ChannelBuffer< T >::ValueType ValueType
Definition: ChannelReadWrite.h:854
uint32_t uint32
Definition: Types.h:64
Base::Shared Shared
Definition: ChannelReadWrite.h:510
ChannelReadWriteCommonBase(ChannelTypePtr channel, ChannelBufferBase::Slot *slot)
Constructs a valid ChannelReadWriteBase object that is assigned to a channel and slot.
Definition: ChannelReadWrite.h:231
AbstractChannel ChannelType
Definition: ChannelReadWrite.h:885
ChannelBuffer< void >::Slot SlotType
Definition: ChannelReadWrite.h:886
void addFlags(uint32 moreFlags) const
For internal use only.
Definition: ChannelReadWrite.h:297
boost::unique_lock< boost::shared_mutex > Lock
Definition: ChannelReadWrite.h:865
void writeSerializedValue(Buffer< uint8 > data)
Definition: ChannelReadWrite.h:752
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:457
void writeJSON(JSONDeserializer &deserializer)
Definition: ChannelReadWrite.h:760
An object that allows read access to data of a channel.
Definition: ChannelReadWrite.h:503
void readJSON(JSONValue &oValue, JSONSerializer &serializer)
Definition: ChannelReadWrite.h:359
#define MIRA_THROW(ex, msg)
Macro for throwing an exception.
Definition: Exception.h:78
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:776
Base::Shared Shared
Definition: ChannelReadWrite.h:667
void writeJSON(const JSONValue &value)
Definition: ChannelReadWrite.h:371
ChannelBuffer< void >::ValueType ValueType
Definition: ChannelReadWrite.h:887
const ValueType & internalValue() const
Returns a const reference on the data.
Definition: ChannelReadWrite.h:430
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:763
Base::Slot Slot
Definition: ChannelReadWrite.h:402
Wrapper class for boost::posix_time::ptime for adding more functionality to it.
Definition: Time.h:418
ChannelReadWriteCommonBase< Derived > Base
Definition: ChannelReadWrite.h:397
const Buffer< uint8 > & readSerializedValue()
Definition: ChannelReadWrite.h:577
ValueType * operator->()
Returns a pointer on the data.
Definition: ChannelReadWrite.h:747
ValueType & internalValue()
Returns a reference on the data.
Definition: ChannelReadWrite.h:469
bool isValid() const
Returns true, if data was assigned to the ChannelRead or ChannelWrite and if this data is locked...
Definition: ChannelReadWrite.h:247
Definition: ChannelReadWrite.h:74
boost::shared_ptr< Shared > SharedPtr
Definition: ChannelReadWrite.h:217
ChannelWrite()
Default constructor that constructs a ChannelWrite object that is invalid at the beginning and contai...
Definition: ChannelReadWrite.h:683
Deserializer for serializing objects from JSON format.
Definition: JSONSerializer.h:406
ChannelReadWriteTraits< DerivedContainer >::Lock Lock
Definition: ChannelReadWrite.h:90
void writeJSON(JSONDeserializer &deserializer)
Definition: ChannelReadWrite.h:376
void writeXML(const XMLDom::const_iterator &node)
Definition: ChannelReadWrite.h:381
Shared::Slot Slot
Definition: ChannelReadWrite.h:222
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:551
uint8_t uint8
Definition: Types.h:62
ChannelRead()
Default constructor that constructs a ChannelRead object that is invalid at the beginning and contain...
Definition: ChannelReadWrite.h:525
ChannelReadWriteBase< ChannelWrite< T >, T > Base
Definition: ChannelReadWrite.h:664
bool empty() const
Checks if the buffer is empty (used size == 0).
Definition: Buffer.h:299
ValueType & operator*()
Returns a reference on the data.
Definition: ChannelReadWrite.h:714
TypeMetaPtr getTypeMeta() const
Definition: ChannelReadWrite.h:263
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:276
void writeXML(const XMLDom::const_iterator &node)
Definition: ChannelReadWrite.h:764
ChannelReadWriteBase< ChannelRead< T >, T > Base
Definition: ChannelReadWrite.h:507
ChannelType * ChannelTypePtr
Definition: ChannelReadWrite.h:159
static Time now()
Returns the current utc based time.
Definition: Time.h:481
const std::string & getChannelID()
Definition: ChannelReadWrite.h:254
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:221
boost::shared_ptr< TypeMeta > TypeMetaPtr
Definition: MetaSerializer.h:309
ChannelBufferBase::Slot * slot
Definition: ChannelReadWrite.h:187
Definition: ChannelReadWrite.h:212
Buffer< uint8 > readSerializedValue(std::list< BinarySerializerCodecPtr > &codecs, uint8 formatVersion, bool orLower)
Definition: ChannelReadWrite.h:347
const Buffer< uint8 > & readSerializedValue()
Definition: ChannelReadWrite.h:319
ChannelReadWriteTraits< DerivedContainer >::ValueType ValueType
Definition: ChannelReadWrite.h:157
void writeSerializedValue(Buffer< uint8 > data)
Definition: ChannelReadWrite.h:366
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:305
ConcreteChannel< T > ChannelType
Definition: ChannelReadWrite.h:862
Container for storing a single data element in the linked list.
Definition: ChannelBuffer.h:164
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:572
ChannelReadCopy< Derived > Shared
Definition: ChannelReadWrite.h:842
static void discard(Shared *shared)
Definition: ChannelReadWrite.h:819
#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:228
std::string getTypename() const
Definition: ChannelReadWrite.h:259
ChannelTypePtr channel
pointer to the channel our data/slot belongs to
Definition: ChannelReadWrite.h:130
ChannelReadWriteShared< ChannelWrite< void > > Shared
Definition: ChannelReadWrite.h:889
ConcreteChannel< T > ChannelType
Definition: ChannelReadWrite.h:852
Base::ValueType ValueType
Definition: ChannelReadWrite.h:452
boost::shared_lock< boost::shared_mutex > Lock
Definition: ChannelReadWrite.h:878
void readJSON(JSONValue &oValue)
Definition: ChannelReadWrite.h:595
Shared::ValueType ValueType
Definition: ChannelReadWrite.h:223
SharedPtr shared
Definition: ChannelReadWrite.h:387
Base::ValueType ValueType
Definition: ChannelReadWrite.h:512
boost::unique_lock< boost::shared_mutex > Lock
Definition: ChannelReadWrite.h:888
void writeJSON(const JSONValue &value)
Definition: ChannelReadWrite.h:756
Definition: ChannelReadWrite.h:834
ValueType & internalValue()
Returns a reference on the data.
Definition: ChannelReadWrite.h:420
Buffer< uint8 > readSerializedValue(std::list< BinarySerializerCodecPtr > &codecs)
Definition: ChannelReadWrite.h:585
ChannelReadWriteBase(ChannelTypePtr channel, ChannelBufferBase::Slot *slot)
Constructs a valid ChannelReadWriteBase object that is assigned to a channel and slot.
Definition: ChannelReadWrite.h:411
void readJSON(JSONValue &oValue, JSONSerializer &serializer)
Definition: ChannelReadWrite.h:599
Base::ChannelTypePtr ChannelTypePtr
Definition: ChannelReadWrite.h:401
ChannelBuffer< void >::ValueType ValueType
Definition: ChannelReadWrite.h:877
ChannelReadWriteShared< ChannelRead< void > > Shared
Definition: ChannelReadWrite.h:879
Definition: LoggingCore.h:75
json::Value JSONValue
Imports the json::Value type into mira namespace.
Definition: JSON.h:361
Base class for all framework channels.
ChannelReadWriteTraits< DerivedContainer >::ValueType ValueType
Definition: ChannelReadWrite.h:92
Definition: ChannelReadWrite.h:393
ChannelReadWriteBase(ChannelTypePtr channel, ChannelBufferBase::Slot *slot)
Constructs a valid ChannelReadWriteBase object that is assigned to a channel and slot.
Definition: ChannelReadWrite.h:460
Base::ValueType ValueType
Definition: ChannelReadWrite.h:669
Buffer< uint8 > readSerializedValue(std::list< BinarySerializerCodecPtr > &codecs, uint8 formatVersion, bool orLower)
Definition: ChannelReadWrite.h:589
MockLock lock
Definition: ChannelReadWrite.h:201
Channel< T > getChannel()
Returns a write-only channel proxy object of the underlying channel.
ChannelReadWriteShared< Derived > Shared
Definition: ChannelReadWrite.h:836
Buffer< uint8 > readSerializedValue(std::list< BinarySerializerCodecPtr > &codecs)
Same as above, but allows to specify codecs for serialization.
Definition: ChannelReadWrite.h:342
ChannelReadWriteTraits< Derived >::Shared Shared
Definition: ChannelReadWrite.h:216
ChannelReadSelectCopy< ChannelRead< T >, T >::Shared Shared
Definition: ChannelReadWrite.h:856
const Time & getTimestamp() const
Definition: ChannelReadWrite.h:267
static void finish(Shared *shared)
Definition: ChannelReadWrite.h:808
ChannelReadWriteTraits< DerivedContainer >::ChannelType ChannelType
Definition: ChannelReadWrite.h:89
const Buffer< uint8 > & readSerializedValue(uint8 formatVersion, bool orLower)
Definition: ChannelReadWrite.h:581