13 #include <vlutil/vlString.h>
15 #include <vl/objClassDesc.h>
16 #include <vl/hlaStateEncoder.h>
19 namespace makVrfVrlinkExtToolkit
21 template <
typename StateRepType,
typename EncoderType>
28 DtExerciseConn* exConn,
29 DtObjClassDesc* classDesc) :
EncoderType(exConn, classDesc) {}
51 RTI::AttributeHandleValuePairSet* attrs,
52 RTI::AttributeHandle attrHandle)
56 unsigned srLength = 0;
58 attrs->add(attrHandle, (
char*)srValue, srLength);
68 if (classDesc->isOfClass(this->myClassDesc->handle()))
71 <StateRepType,
EncoderType>(this->myExConn, classDesc);
73 std::map<RTI::AttributeHandle,DtHlaStateEncoder::DtAttributeEncoder>::const_iterator
74 encIter = this->myEncoderList.begin();
75 std::map<RTI::AttributeHandle,DtHlaStateEncoder::DtAttributeEncoder>::const_iterator
76 encEnd = this->myEncoderList.end();
77 for(; encIter != encEnd; ++encIter)
79 enc->addEncoder(encIter->first, encIter->second);
82 std::map<RTI::AttributeHandle,DtHlaStateEncoder::DtAttributeChecker>::const_iterator
83 chIter = this->myCheckerList.begin();
84 std::map<RTI::AttributeHandle,DtHlaStateEncoder::DtAttributeChecker>::const_iterator
85 chEnd = this->myCheckerList.end();
86 for(; chIter != chEnd; ++chIter)
88 enc->addChecker(chIter->first, chIter->second);
95 DtWarn <<
"DtGenericAttributeEncoder: ClassDesc is not a subclass. "
96 <<
"Returning a normal clone " << std::endl;
115 const RTI::AttributeHandleSet& neededAttrs,
116 const RTI::AttributeHandleSet& includeThese,
119 if (!this->myClassDesc)
128 RTI::AttributeHandleValuePairSet* avList =
129 new RTI::AttributeHandleValuePairSet(msg->handleMap());
131 HandleValueMap* avList = msg->handleMap();
135 RTI::AttributeHandleSet::const_iterator end = neededAttrs.end();
136 RTI::AttributeHandleSet::const_iterator pos = neededAttrs.begin();
137 for (; pos != end; ++pos)
139 RTI::AttributeHandle handle = *pos;
141 for (RTI::ULong index = 0; index < neededAttrs.size(); index++)
143 RTI::AttributeHandle handle = neededAttrs.getHandle(index);
146 DtHlaStateEncoder::DtAttributeEncoder enc = this->encoder(handle);
149 if (handle != this->myClassDesc->privilegeHandle())
151 DtHlaStateEncoder::DtAttributeEncoder unknownEncoder = this->myClassDesc->unknownAttributeEncoder();
157 if(includeThese.find(handle) != includeThese.end() ||
159 if(includeThese.isMember(handle) ||
163 (*unknownEncoder)(stateRep, avList, handle);
167 else if (!this->myReportedWarning[handle])
169 DtWarn <<
"DtHlaStateEncoder for class "<< this->myClassDesc->name()
170 <<
" has no encoder for attribute "
171 << this->myClassDesc->attributeNameByHandle(handle)
177 DtHlaStateEncoder::DtAttributeChecker check = this->checker(handle);
180 if (handle != this->myClassDesc->privilegeHandle() && !this->myReportedWarning[handle])
182 DtWarn <<
"DtHlaStateEncoder for class "<< this->myClassDesc->name()
183 <<
" has no checker for attribute "
184 << this->myClassDesc->attributeNameByHandle(handle) << std::endl;
190 this->myReportedWarning[handle] =
true;
195 if ( includeThese.find(handle) != includeThese.end() ||
196 (*check)(stateRep, asSeenByRemote))
198 if (includeThese.isMember(handle) ||
199 (*check)(stateRep, asSeenByRemote))
202 (*enc)(stateRep, avList, handle);
214 DtExerciseConn* exConn,
215 DtObjClassDesc* classDesc)
227 RTI::AttributeHandle attrHandle)
234 unsigned srLength = 0;
235 unsigned asbrLength = 0;
239 return (srLength != asbrLength ||
240 memcmp(srValue, asbrValue, srLength) != 0);