- return aRes;
-}
-
-std::shared_ptr<ModelAPI_AttributeBoolean> Model_Data::boolean(const std::string& theID)
-{
- std::map<std::string, std::shared_ptr<ModelAPI_Attribute> >::iterator aFound =
- myAttrs.find(theID);
- if (aFound == myAttrs.end()) {
- // TODO: generate error on unknown attribute request and/or add mechanism for customization
- return std::shared_ptr<ModelAPI_AttributeBoolean>();
- }
- std::shared_ptr<ModelAPI_AttributeBoolean> aRes = std::dynamic_pointer_cast<
- ModelAPI_AttributeBoolean>(aFound->second);
- if (!aRes) {
- // TODO: generate error on invalid attribute type request
- }
- return aRes;
-}
-
-std::shared_ptr<ModelAPI_AttributeString> Model_Data::string(const std::string& theID)
-{
- std::map<std::string, std::shared_ptr<ModelAPI_Attribute> >::iterator aFound =
- myAttrs.find(theID);
- if (aFound == myAttrs.end()) {
- // TODO: generate error on unknown attribute request and/or add mechanism for customization
- return std::shared_ptr<ModelAPI_AttributeString>();
- }
- std::shared_ptr<ModelAPI_AttributeString> aRes =
- std::dynamic_pointer_cast<ModelAPI_AttributeString>(aFound->second);
- if (!aRes) {
- // TODO: generate error on invalid attribute type request
- }
- return aRes;
-
-}
-
-std::shared_ptr<ModelAPI_AttributeReference> Model_Data::reference(const std::string& theID)
-{
- std::map<std::string, std::shared_ptr<ModelAPI_Attribute> >::iterator aFound =
- myAttrs.find(theID);
- if (aFound == myAttrs.end()) {
- // TODO: generate error on unknown attribute request and/or add mechanism for customization
- return std::shared_ptr<ModelAPI_AttributeReference>();
- }
- std::shared_ptr<ModelAPI_AttributeReference> aRes = std::dynamic_pointer_cast<
- ModelAPI_AttributeReference>(aFound->second);
- if (!aRes) {
- // TODO: generate error on invalid attribute type request
- }
- return aRes;
-}
-
-std::shared_ptr<ModelAPI_AttributeSelection> Model_Data::selection(const std::string& theID)
-{
- std::map<std::string, std::shared_ptr<ModelAPI_Attribute> >::iterator aFound =
- myAttrs.find(theID);
- if (aFound == myAttrs.end()) {
- // TODO: generate error on unknown attribute request and/or add mechanism for customization
- return std::shared_ptr<ModelAPI_AttributeSelection>();
- }
- std::shared_ptr<ModelAPI_AttributeSelection> aRes =
- std::dynamic_pointer_cast<ModelAPI_AttributeSelection>(aFound->second);
- if (!aRes) {
- // TODO: generate error on invalid attribute type request
- }
- return aRes;
-}
-
-std::shared_ptr<ModelAPI_AttributeSelectionList>
- Model_Data::selectionList(const std::string& theID)
-{
- std::map<std::string, std::shared_ptr<ModelAPI_Attribute> >::iterator aFound =
- myAttrs.find(theID);
- if (aFound == myAttrs.end()) {
- // TODO: generate error on unknown attribute request and/or add mechanism for customization
- return std::shared_ptr<ModelAPI_AttributeSelectionList>();
- }
- std::shared_ptr<ModelAPI_AttributeSelectionList> aRes =
- std::dynamic_pointer_cast<ModelAPI_AttributeSelectionList>(aFound->second);
- if (!aRes) {
- // TODO: generate error on invalid attribute type request
- }
- return aRes;
-}
-
-std::shared_ptr<ModelAPI_AttributeRefAttr> Model_Data::refattr(const std::string& theID)
-{
- std::map<std::string, std::shared_ptr<ModelAPI_Attribute> >::iterator aFound =
- myAttrs.find(theID);
- if (aFound == myAttrs.end()) {
- // TODO: generate error on unknown attribute request and/or add mechanism for customization
- return std::shared_ptr<ModelAPI_AttributeRefAttr>();
- }
- std::shared_ptr<ModelAPI_AttributeRefAttr> aRes = std::dynamic_pointer_cast<
- ModelAPI_AttributeRefAttr>(aFound->second);
- if (!aRes) {
- // TODO: generate error on invalid attribute type request
- }
- return aRes;
-}
-
-std::shared_ptr<ModelAPI_AttributeRefList> Model_Data::reflist(const std::string& theID)
-{
- std::map<std::string, std::shared_ptr<ModelAPI_Attribute> >::iterator aFound =
- myAttrs.find(theID);
- if (aFound == myAttrs.end()) {
- // TODO: generate error on unknown attribute request and/or add mechanism for customization
- return std::shared_ptr<ModelAPI_AttributeRefList>();
- }
- std::shared_ptr<ModelAPI_AttributeRefList> aRes = std::dynamic_pointer_cast<
- ModelAPI_AttributeRefList>(aFound->second);
- if (!aRes) {
- // TODO: generate error on invalid attribute type request
- }
- return aRes;
-}
+// implement nice getting methods for all ModelAPI attributes
+GET_ATTRIBUTE_BY_ID(ModelAPI_AttributeDocRef, document);
+GET_ATTRIBUTE_BY_ID(ModelAPI_AttributeDouble, real);
+GET_ATTRIBUTE_BY_ID(ModelAPI_AttributeInteger, integer);
+GET_ATTRIBUTE_BY_ID(ModelAPI_AttributeBoolean, boolean);
+GET_ATTRIBUTE_BY_ID(ModelAPI_AttributeString, string);
+GET_ATTRIBUTE_BY_ID(ModelAPI_AttributeReference, reference);
+GET_ATTRIBUTE_BY_ID(ModelAPI_AttributeSelection, selection);
+GET_ATTRIBUTE_BY_ID(ModelAPI_AttributeSelectionList, selectionList);
+GET_ATTRIBUTE_BY_ID(ModelAPI_AttributeRefAttr, refattr);
+GET_ATTRIBUTE_BY_ID(ModelAPI_AttributeRefList, reflist);