CoherentChangeControl.cpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008 #include "DCPS/DdsDcps_pch.h"
00009
00010 #ifndef OPENDDS_NO_OBJECT_MODEL_PROFILE
00011
00012 #include "CoherentChangeControl.h"
00013 #include "Serializer.h"
00014 #include "GuidConverter.h"
00015 #include "dds/DdsDcpsGuidTypeSupportImpl.h"
00016 #include "dds/DCPS/PoolAllocator.h"
00017
00018 #include <iomanip>
00019 #include <iostream>
00020 #include <stdexcept>
00021
00022
00023 #if !defined (__ACE_INLINE__)
00024 #include "CoherentChangeControl.inl"
00025 #endif
00026
00027 OPENDDS_BEGIN_VERSIONED_NAMESPACE_DECL
00028
00029 namespace OpenDDS {
00030 namespace DCPS {
00031
00032 ACE_CDR::Boolean
00033 operator<<(Serializer& serializer, CoherentChangeControl& value)
00034 {
00035 if (!(serializer << value.coherent_samples_.num_samples_) ||
00036 !(serializer << value.coherent_samples_.last_sample_) ||
00037 !(serializer << ACE_OutputCDR::from_boolean(value.group_coherent_))) {
00038 return false;
00039 }
00040
00041 if (value.group_coherent_) {
00042 if (!(serializer << value.publisher_id_) ||
00043 !(serializer << static_cast<ACE_UINT32>(value.group_coherent_samples_.size()))) {
00044 return false;
00045 }
00046 GroupCoherentSamples::iterator itEnd = value.group_coherent_samples_.end();
00047 for (GroupCoherentSamples::iterator it =
00048 value.group_coherent_samples_.begin(); it != itEnd; ++it) {
00049 if (!(serializer << it->first) ||
00050 !(serializer << it->second.num_samples_) ||
00051 !(serializer << it->second.last_sample_)) {
00052 return false;
00053 }
00054 }
00055 }
00056
00057 return serializer.good_bit();
00058 }
00059
00060 ACE_CDR::Boolean
00061 operator>>(Serializer& serializer, CoherentChangeControl& value)
00062 {
00063 if (!(serializer >> value.coherent_samples_.num_samples_) ||
00064 !(serializer >> value.coherent_samples_.last_sample_) ||
00065 !(serializer >> ACE_InputCDR::to_boolean(value.group_coherent_))) {
00066 return false;
00067 }
00068
00069 if (value.group_coherent_) {
00070 ACE_UINT32 sz = 0;
00071 if (!(serializer >> value.publisher_id_) ||
00072 !(serializer >> sz)) {
00073 return false;
00074 }
00075
00076 for (ACE_UINT32 i = 0; i < sz; ++i) {
00077 PublicationId writer(GUID_UNKNOWN);
00078 ACE_UINT32 num_sample = 0;
00079 ACE_INT16 last_sample = 0;
00080
00081 if (!(serializer >> writer) ||
00082 !(serializer >> num_sample) ||
00083 !(serializer >> last_sample)) {
00084 return false;
00085 }
00086
00087 std::pair<GroupCoherentSamples::iterator, bool> pair =
00088 value.group_coherent_samples_.insert(GroupCoherentSamples::value_type(
00089 writer, WriterCoherentSample(num_sample, last_sample)));
00090 if (!pair.second) {
00091 return false;
00092 }
00093 }
00094 }
00095
00096 return serializer.good_bit();
00097 }
00098
00099
00100 extern OpenDDS_Dcps_Export
00101 std::ostream& operator<<(std::ostream& str, const CoherentChangeControl& value)
00102 {
00103 str << "num_samples: " << std::dec << value.coherent_samples_.num_samples_
00104 << ", last_sample: " << value.coherent_samples_.last_sample_.getValue()
00105 << ", ";
00106 if (value.group_coherent_) {
00107 GuidConverter converter(value.publisher_id_);
00108 str << "publisher: " << std::dec << OPENDDS_STRING(converter).c_str() << ", ";
00109 str << "group size: " << std::dec << value.group_coherent_samples_.size()
00110 << ", ";
00111 GroupCoherentSamples::const_iterator itEnd =
00112 value.group_coherent_samples_.end();
00113 for (GroupCoherentSamples::const_iterator it =
00114 value.group_coherent_samples_.begin(); it != itEnd; ++it) {
00115 GuidConverter converter(it->first);
00116 str << "writer: " << OPENDDS_STRING(converter).c_str() << ", "
00117 << "num_samples: " << it->second.num_samples_ << ", "
00118 << "last_sample: " << it->second.last_sample_.getValue() << std::endl;
00119 }
00120 }
00121 return str;
00122 }
00123
00124 }
00125 }
00126
00127 OPENDDS_END_VERSIONED_NAMESPACE_DECL
00128
00129 #endif // OPENDDS_NO_OBJECT_MODEL_PROFILE