7 #ifndef __data_Accessor_h__ 8 #define __data_Accessor_h__ 10 #if FE_CODEGEN<FE_DEBUG 11 #define FE_ATTRIBUTE_DEBUG 12 #define FE_ACCESSOR_DEBUG 43 void initialize(
Scope *pScope,
55 const String &attributetype);
68 operator FE_UWORD()
const;
69 FE_UWORD index(
void)
const;
103 bool check(Layout &rL)
const;
108 const String &name(
void)
const;
113 void typeCheck(
const String &attribute);
143 const T operator()(
const RecordSB& r)
const;
159 T &operator()(
const RecordSB& r,
const char *message);
167 T *queryAttribute(
const RecordSB& r);
182 const T operator()(
const RecordAV& r)
const;
198 T &operator()(
const RecordAV& r,
const char *message);
202 bool queryAttribute(
const RecordAV& r, T *&data);
206 T *queryAttribute(
const RecordAV& r);
218 bool operator()(
const RecordAV& record, T &data);
220 bool operator()(
const RecordSB& record, T &data);
223 void registerDefault(T *pT);
229 (*this)(BaseAccessor::m_optional_record) = a_value;
234 return &((*this)(BaseAccessor::m_optional_record));
238 return (*
this)(BaseAccessor::m_optional_record);
242 return (*
this)(BaseAccessor::m_optional_record);
255 m_typeInfo =
TypeInfo(getTypeId<void>());
259 m_typeInfo =
TypeInfo(getTypeId<void>());
260 setup(scope, attribute);
273 inline bool BaseAccessor::operator==(
const BaseAccessor &other)
const 275 if(m_index != other.m_index) {
return false; }
276 if(!(m_hpScope == other.m_hpScope)) {
return false; }
280 inline bool BaseAccessor::operator<(
const BaseAccessor &other)
const 282 return (m_index < other.m_index);
286 inline BaseAccessor::operator FE_UWORD()
const 291 inline FE_UWORD BaseAccessor::index(
void)
const 296 #ifdef FE_ATTRIBUTE_DEBUG 297 #define FE_SCOPE_CHECK(s) \ 298 if(!m_hpScope.isValid()) \ 300 feX("FE_SCOPE_CHECK", \ 301 "Accessor for \'%s\' is not initialized", \ 302 s->attribute(m_index)->name().c_str()); \ 306 feX("FE_SCOPE_CHECK", \ 307 "Accessor for \'%s\' is not bound to the same scope as Record", \ 308 m_hpScope->attribute(m_index)->name().c_str()); \ 311 #define FE_SCOPE_CHECK(s) 316 FE_SCOPE_CHECK(record.
layout()->scope());
317 return record.
layout()->checkAttribute(m_index);
322 FE_SCOPE_CHECK(record.
layout()->scope());
323 return record.
layout()->checkAttribute(m_index);
328 FE_SCOPE_CHECK(record->
layout()->scope());
329 return record->
layout()->checkAttribute(m_index);
334 FE_SCOPE_CHECK(rspRA->layout()->scope());
335 return rspRA->layout()->checkAttribute(m_index);
341 FE_SCOPE_CHECK(rRA.
layout()->scope());
342 return rRA.
layout()->checkAttribute(m_index);
347 FE_SCOPE_CHECK(rspL->scope());
348 return rspL->checkAttribute(m_index);
353 FE_SCOPE_CHECK(rL.scope());
354 return rL.checkAttribute(m_index);
359 FE_SCOPE_CHECK(rspL->scope());
360 return rspL->checkAttribute(m_index);
365 FE_SCOPE_CHECK(rL.scope());
366 return rL.checkAttribute(m_index);
371 FE_SCOPE_CHECK(rspL->scope());
372 return rspL->checkAttribute(m_index);
377 FE_SCOPE_CHECK(rL.scope());
378 return rL.checkAttribute(m_index);
383 FE_SCOPE_CHECK(record.
layout()->scope());
384 return record.
layout()->checkAttribute(m_index);
389 FE_SCOPE_CHECK(record.
layout()->scope());
390 return record.
layout()->checkAttribute(m_index);
395 FE_SCOPE_CHECK(record->
layout()->scope());
396 return record->
layout()->checkAttribute(m_index);
401 FE_SCOPE_CHECK(rspRA->layout()->scope());
402 return rspRA->layout()->checkAttribute(m_index);
408 FE_SCOPE_CHECK(rRA.
layout()->scope());
409 return rRA.
layout()->checkAttribute(m_index);
417 m_typeInfo =
TypeInfo(getTypeId<T>());
424 m_typeInfo =
TypeInfo(getTypeId<T>());
425 setup(scope, attribute);
433 #ifdef FE_ATTRIBUTE_DEBUG 434 #define FE_ATTRIBUTE_CHECK(r) \ 437 feX("FE_ATTRIBUTE_CHECK", \ 438 "invalid access: \'%s\' is not in \'%s\'", \ 439 m_hpScope->attribute(m_index)->name().c_str(), \ 440 r.layout()->name().c_str()); \ 443 #define FE_ATTRIBUTE_CHECK(r) 446 #ifdef FE_ATTRIBUTE_DEBUG 447 #define FE_ATTRIBUTE_TYPECHECK(r) \ 448 sp<TypeMaster> spTM = m_hpScope->typeMaster(); \ 449 sp<BaseType> spType = spTM->lookupType(TypeInfo(getTypeId<T>())); \ 450 if(spType != m_hpScope->attribute(m_index)->type()) \ 452 feX("FE_ATTRIBUTE_TYPECHECK", \ 453 "accessor on \'%s\' type mismatch \'%s\' is not \'%s\'\n", \ 454 m_hpScope->attribute(m_index)->name().c_str(), \ 455 spTM->reverseLookup(spType).c_str(), \ 456 spTM->reverseLookup(m_hpScope->attribute(m_index)->type()). \ 460 #define FE_ATTRIBUTE_TYPECHECK(r) 468 m_index = other.m_index;
469 m_hpScope = other.m_hpScope;
470 m_typeInfo = other.m_typeInfo;
480 m_index = other.m_index;
481 m_hpScope = other.m_hpScope;
482 m_typeInfo = other.m_typeInfo;
491 FE_ATTRIBUTE_CHECK(record);
492 FE_ATTRIBUTE_TYPECHECK(record);
494 return record.accessAttribute<T>(m_index);
500 FE_ATTRIBUTE_CHECK(record);
501 FE_ATTRIBUTE_TYPECHECK(record);
502 return record.accessAttribute<T>(m_index);
508 FE_ATTRIBUTE_CHECK(record);
509 FE_ATTRIBUTE_TYPECHECK(record);
510 return record.accessAttribute<T>(m_index);
516 FE_ATTRIBUTE_CHECK(record);
517 FE_ATTRIBUTE_TYPECHECK(record);
518 return record.accessAttribute<T>(m_index);
524 FE_ATTRIBUTE_CHECK((*record));
525 FE_ATTRIBUTE_TYPECHECK(*record);
526 return record->accessAttribute<T>(m_index);
535 feX(e_invalidPointer,
536 (message!=NULL)?message:
"",
537 "invalid record in access of %s",
538 m_hpScope->attribute(m_index)->name().c_str());
543 (message!=NULL)?message:
"",
544 "%s not found in layout %s",
545 m_hpScope->attribute(m_index)->name().c_str(),
546 record.
layout()->name().c_str());
548 return record.accessAttribute<T>(m_index);
555 FE_ATTRIBUTE_CHECK((*rspRA));
556 return rspRA->accessAttribute<T>(m_index, index);
562 FE_ATTRIBUTE_CHECK((*rspRA));
563 return rspRA->accessAttribute<T>(m_index, index);
569 FE_ATTRIBUTE_CHECK((*rhpRA));
570 return rhpRA->accessAttribute<T>(m_index, index);
580 data = &(operator()(record));
591 data = &(operator()(record));
602 return &(operator()(record));
612 return &(operator()(record));
622 return &(operator()(rspRA,index));
632 return &(operator()(record));
639 return (T *)(spLayout->baseOfAV(m_index));
646 FE_ATTRIBUTE_CHECK(record);
647 FE_ATTRIBUTE_TYPECHECK(record);
649 return record.accessAttribute<T>(m_index);
655 FE_ATTRIBUTE_CHECK(record);
656 FE_ATTRIBUTE_TYPECHECK(record);
657 return record.accessAttribute<T>(m_index);
663 FE_ATTRIBUTE_CHECK(record);
664 FE_ATTRIBUTE_TYPECHECK(record);
665 return record.accessAttribute<T>(m_index);
671 FE_ATTRIBUTE_CHECK(record);
672 FE_ATTRIBUTE_TYPECHECK(record);
673 return record.accessAttribute<T>(m_index);
679 FE_ATTRIBUTE_CHECK((*record));
680 FE_ATTRIBUTE_TYPECHECK(*record);
681 return record->accessAttribute<T>(m_index);
691 data = (operator()(record));
702 data = (operator()(record));
711 feX(e_invalidPointer,
712 (message!=NULL)?message:
"",
713 "invalid record in access of %s",
714 m_hpScope->attribute(m_index)->name().c_str());
719 (message!=NULL)?message:
"",
720 "%s not found in layout %s",
721 m_hpScope->attribute(m_index)->name().c_str(),
722 record.
layout()->name().c_str());
724 return record.accessAttribute<T>(m_index);
731 FE_ATTRIBUTE_CHECK((*rspRA));
732 return rspRA->accessAttribute<T>(m_index, index);
738 FE_ATTRIBUTE_CHECK((*rspRA));
739 return rspRA->accessAttribute<T>(m_index, index);
745 FE_ATTRIBUTE_CHECK((*rhpRA));
746 return rhpRA->accessAttribute<T>(m_index, index);
756 data = &(operator()(record));
767 data = &(operator()(record));
778 return &(operator()(record));
788 return &(operator()(record));
799 return &(operator()(rspRA,index));
810 return &(operator()(record));
821 class FE_DL_EXPORT AccessorReadOnly :
public BaseAccessor 824 AccessorReadOnly(
void);
826 ~AccessorReadOnly(
void);
830 AccessorReadOnly<T> &operator=(
const AccessorReadOnly<T> &other);
834 const T operator()(
const RecordSB& r)
const;
842 bool queryAttribute(
const RecordSB& r, T *&data);
848 const T operator()(
const RecordAV& r)
const;
856 bool queryAttribute(
const RecordAV& r, T *&data);
861 bool operator()(
const RecordAV& record, T &data);
863 bool operator()(
const RecordSB& record, T &data);
866 void registerDefault(T *pT);
873 inline AccessorReadOnly<T>::AccessorReadOnly(
void)
876 m_typeInfo =
TypeInfo(getTypeId<T>());
880 inline AccessorReadOnly<T>::AccessorReadOnly(
sp<Scope> scope,
const String &attribute)
883 m_typeInfo =
TypeInfo(getTypeId<T>());
884 setup(scope, attribute);
888 inline AccessorReadOnly<T>::~AccessorReadOnly(
void)
893 inline AccessorReadOnly<T>::AccessorReadOnly(
const Accessor<T> &other)
897 m_index = other.m_index;
898 m_hpScope = other.m_hpScope;
899 m_typeInfo = other.m_typeInfo;
905 inline AccessorReadOnly<T>& AccessorReadOnly<T>::operator=(
906 const AccessorReadOnly<T>& other)
910 m_index = other.m_index;
911 m_hpScope = other.m_hpScope;
912 m_typeInfo = other.m_typeInfo;
919 inline const T AccessorReadOnly<T>::operator()(
const RecordSB& record)
const 921 FE_ATTRIBUTE_CHECK(record);
922 FE_ATTRIBUTE_TYPECHECK(record);
923 return record.accessAttribute<T>(m_index);
927 inline const T AccessorReadOnly<T>::operator()(
const WeakRecordSB &record)
const 929 FE_ATTRIBUTE_CHECK(record);
930 FE_ATTRIBUTE_TYPECHECK(record);
931 return record.accessAttribute<T>(m_index);
935 inline const T &AccessorReadOnly<T>::operator()(
sp<RecordArraySB>& rspRA, FE_UWORD index)
const 937 FE_ATTRIBUTE_CHECK((*rspRA));
938 return rspRA->accessAttribute<T>(m_index, index);
942 inline bool AccessorReadOnly<T>::queryAttribute(
const RecordSB& record, T *&data)
948 data = &(operator()(record));
953 inline bool AccessorReadOnly<T>::queryAttribute(
const WeakRecordSB record, T *&data)
959 data = &(operator()(record));
964 inline const T AccessorReadOnly<T>::operator()(
const RecordAV& record)
const 966 FE_ATTRIBUTE_CHECK(record);
967 FE_ATTRIBUTE_TYPECHECK(record);
968 return record.accessAttribute<T>(m_index);
973 inline const T AccessorReadOnly<T>::operator()(
const WeakRecordAV &record)
const 975 FE_ATTRIBUTE_CHECK(record);
976 FE_ATTRIBUTE_TYPECHECK(record);
977 return record.accessAttribute<T>(m_index);
981 inline bool AccessorReadOnly<T>::operator()(
const RecordSB& record, T &data)
987 data = (operator()(record));
992 inline bool AccessorReadOnly<T>::operator()(
const WeakRecordSB& record, T &data)
998 data = (operator()(record));
1004 inline const T &AccessorReadOnly<T>::operator()(
sp<RecordArrayAV>& rspRA, FE_UWORD index)
const 1006 FE_ATTRIBUTE_CHECK((*rspRA));
1007 return rspRA->accessAttribute<T>(m_index, index);
1012 inline bool AccessorReadOnly<T>::queryAttribute(
const RecordAV& record, T *&data)
1018 data = &(operator()(record));
1023 inline bool AccessorReadOnly<T>::queryAttribute(
const WeakRecordAV record, T *&data)
1029 data = &(operator()(record));
1035 inline void AccessorReadOnly<T>::registerDefault(T *pT)
1041 class FE_DL_EXPORT AccessorW :
public Accessor<T> { };
1044 class FE_DL_EXPORT AccessorR :
public AccessorReadOnly<T> { };
sp< Layout > layout(void)
Return the Layout.
Definition: RecordArraySB.h:221
Homogeneous collection of Records.
Definition: RecordArrayAV.h:32
sp< Layout > layout(void) const
Return the Layout.
Definition: RecordAV.h:174
bool isValid(void) const
Return true if the Record points to a valid state block.
Definition: RecordSB.h:184
kernel
Definition: namespace.dox:3
bool queryAttribute(const RecordSB &r, T *&data)
Return true if the attribute exists in record.
Definition: Accessor.h:574
const sp< LayoutSB > & layout(void) const
Return the Layout.
Definition: WeakRecordSB.h:251
Generic exception carrying a fe::String payload.
Definition: Exception.h:34
The main data access class for the data system.
Definition: Accessor.h:128
sp< Layout > layout(void) const
Return the Layout.
Definition: RecordSB.h:189
C++ type_info wrapper.
Definition: Type.h:20
void bind(const WeakRecord &a_record)
optionally bind to a record
Definition: Accessor.h:111
Type inspecific Accessor.
Definition: Accessor.h:26
Safe handle for shared pointer.
Definition: Handled.h:61
BWORD operator==(const DualString &s1, const DualString &s2)
Compare two DualString's.
Definition: DualString.h:208
Automatically reference-counted string container.
Definition: String.h:128
const sp< LayoutAV > & layout(void) const
Return the Layout.
Definition: WeakRecordAV.h:249
bool check(const RecordSB &r) const
Return true if record has attribute.
Definition: Accessor.h:314
Reference to an instance of a Layout.
Definition: RecordSB.h:35
Reference to an instance of a Layout.
Definition: RecordAV.h:25
Record "type" definition.
Definition: LayoutSB.h:32
Layout namespace.
Definition: Scope.h:71
bool isValid(void) const
Return true if the Record points to a valid state block.
Definition: RecordAV.h:195
T & operator()(const RecordSB &r)
Return the attribute.
Definition: Accessor.h:489
Record "type" definition.
Definition: LayoutAV.h:30
Non-persistent reference to an instance of a Layout.
Definition: WeakRecordAV.h:17
sp< Layout > layout(void)
Return the Layout.
Definition: RecordArrayAV.h:257
Homogeneous collection of Records.
Definition: RecordArraySB.h:40
Non-persistent reference to an instance of a Layout.
Definition: WeakRecordSB.h:17