29 template <
class CommonBaseT,
class ClassT>
30 struct ClassMemberInfo;
31 template <
class CommonBaseT,
class ClassT>
34 template <
class CommonBaseT>
45 template <
class ClassType,
class MemberType>
47 className{GetTypeString<ClassType>()},
48 memberName{memberName},
49 memberTypeName{GetTypeString<MemberType>()},
50 numberOfFields{DataFieldsInfo<MemberType>::GetNumberOfFields()},
51 fieldToType{MakeFieldToTypeFunctors<ClassType>(numberOfFields, ptr)},
52 toVariants_{MakeToVariantsFunctor<ClassType>(ptr)}
57 fieldNames.reserve(numberOfFields);
58 if (numberOfFields == 1)
60 fieldNames.emplace_back(memberName);
64 for (
auto& name : DataFieldsInfo<MemberType>::GetFieldNames())
66 fieldNames.emplace_back(memberName +
"." + std::move(name));
88 return memberTypeName;
95 return numberOfFields;
102 return fieldNames.at(i);
110 return fieldToType.at(i).toBool(ptr, out);
118 return fieldToType.at(i).toByte(ptr, out);
126 return fieldToType.at(i).toShort(ptr, out);
134 return fieldToType.at(i).toInt(ptr, out);
142 return fieldToType.at(i).toLong(ptr, out);
150 return fieldToType.at(i).toFloat(ptr, out);
158 return fieldToType.at(i).toDouble(ptr, out);
166 return fieldToType.at(i).toString(ptr, out);
169 const std::type_info&
173 return *fieldToType.at(i).typeId;
177 std::map<std::string, VariantBasePtr>
180 return toVariants_(
this, timestamp, ptr);
184 using ToVariantsFunctorType =
192 using FieldToFunctorType = std::function<void(
const CommonBaseType*,
T&)>;
193 FieldToFunctorType<bool> toBool;
194 FieldToFunctorType<Ice::Byte>
toByte;
195 FieldToFunctorType<Ice::Short> toShort;
196 FieldToFunctorType<Ice::Int>
toInt;
197 FieldToFunctorType<Ice::Long> toLong;
198 FieldToFunctorType<Ice::Float>
toFloat;
199 FieldToFunctorType<Ice::Double> toDouble;
200 FieldToFunctorType<std::string>
toString;
201 const std::type_info* typeId;
204 template <
class ClassType,
class MemberType,
class MemberPtrClassType>
205 static std::vector<FieldToType>
206 MakeFieldToTypeFunctors(std::size_t numberOfFields, MemberType MemberPtrClassType::*ptr)
208 std::vector<FieldToType> result;
209 result.reserve(numberOfFields);
210 for (std::size_t i = 0; i < numberOfFields; ++i)
212 result.emplace_back();
213 auto& fieldData = result.back();
215 #define make_getter(Type) \
216 [i, ptr](const CommonBaseType* ptrBase, Type& out) \
218 const ClassType* cptr = dynamic_cast<const ClassType*>(ptrBase); \
219 ARMARX_CHECK_NOT_NULL(cptr); \
220 DataFieldsInfo<MemberType>::GetDataFieldAs(i, cptr->*ptr, out); \
236 template <
class ClassType,
class MemberType,
class MemberPtrClassType>
237 static ToVariantsFunctorType
238 MakeToVariantsFunctor(MemberType MemberPtrClassType::*ptr)
244 const ClassType* cptr =
dynamic_cast<const ClassType*
>(ptrBase);
246 return DataFieldsInfo<MemberType>::ToVariants(cptr->*ptr,
247 thisptr->getMemberName(),
249 thisptr->variantReportFrame(),
250 thisptr->variantReportAgent());
254 template <
class BaseType,
class ClassT>
256 template <
class BaseType,
class ClassT>
259 const std::string className;
260 const std::string memberName;
261 const std::string memberTypeName;
263 const std::size_t numberOfFields;
264 const std::vector<FieldToType> fieldToType;
265 std::vector<std::string> fieldNames;
267 ToVariantsFunctorType toVariants_;
268 bool setVariantReportFrame_{
false};
269 std::function<std::string()> variantReportFrame{[] {
return ""; }};
270 std::function<std::string()> variantReportAgent{[] {
return ""; }};
273 template <
class CommonBaseT,
class ClassT>
274 struct ClassMemberInfoEntryConfigurator
284 e.fieldNames = std::move(fieldNames);
291 e.setVariantReportFrame_ =
true;
292 e.variantReportFrame = [frame] {
return frame; };
293 e.variantReportAgent = [agent] {
return agent; };
300 e.setVariantReportFrame_ =
true;
301 e.variantReportFrame = std::move(frame);
302 e.variantReportAgent = [agent] {
return agent; };
309 e.setVariantReportFrame_ =
true;
310 e.variantReportFrame = [frame] {
return frame; };
311 e.variantReportAgent = std::move(agent);
317 std::function<std::string()> frame)
319 e.setVariantReportFrame_ =
true;
320 e.variantReportFrame = std::move(frame);
321 e.variantReportAgent = std::move(agent);
327 std::function<std::map<std::string, VariantBasePtr>(
const IceUtil::Time&,
336 return f(timestamp, ptr);