42 #ifndef STANDARD_COMPOSITION_RELATIONSHIPS_PACK_H
43 #define STANDARD_COMPOSITION_RELATIONSHIPS_PACK_H
45 #include "Moocho_ConfigDefs.hpp"
46 #include "Teuchos_Assert.hpp"
48 namespace StandardCompositionRelationshipsPack {
59 {
public:
NoRefSet(
const std::string& what_arg) : std::logic_error(what_arg) {}};
62 inline void ThrowNoRefSet(
const char func_name[],
const char name[])
66 ,func_name <<
": The reference for \'" << name <<
"\' has not been set yet"
71 template<
class ContainedClass>
72 inline void assert_role_name_set(
const ContainedClass* role_name_,
const char func_name[]
75 if(!role_name_) ThrowNoRefSet(func_name, name);
79 template<
class ContainedClass>
80 inline void set_role_name(ContainedClass*& role_name_,
bool& owns_role_name_,
const char name[]
81 , ContainedClass* role_name,
bool owns_role_name)
83 if(owns_role_name_ && role_name_ != role_name)
delete role_name_;
84 role_name_ = role_name; owns_role_name_ = owns_role_name;
88 template<
class ContainedClass>
89 inline ContainedClass* get_role_name(ContainedClass* role_name_,
bool owns_role_name_
96 template<
class ContainedClass>
97 inline void set_owns_role_name(ContainedClass*& role_name_,
bool& owns_role_name_
98 ,
const char name[],
bool owns_role_name)
100 assert_role_name_set(role_name_,
"set_owns_role_name()", name);
101 owns_role_name_ = owns_role_name;
105 template<
class ContainedClass>
106 inline bool owns_role_name(ContainedClass* role_name_,
bool owns_role_name_,
const char name[])
108 assert_role_name_set(role_name_,
"owns_role_name()", name);
109 return owns_role_name_;
113 template<
class ContainedClass>
114 inline ContainedClass& role_name(ContainedClass* role_name_,
bool owns_role_name_,
const char name[])
116 assert_role_name_set(role_name_,
"role_name()", name);
121 template<
class ContainedClass>
122 inline const ContainedClass& role_name(
const ContainedClass* role_name_,
bool owns_role_name_,
const char name[])
124 assert_role_name_set(role_name_,
"role_name()", name);
129 template<
class ContainedClass>
130 inline const ContainedClass& const_role_name(
const ContainedClass* role_name_,
bool owns_role_name_,
const char name[])
132 assert_role_name_set(role_name_,
"role_name()", name);
138 template<
class ContainedClass>
139 inline void destory_container_obj(ContainedClass* role_name_,
bool owns_role_name_)
141 if(owns_role_name_)
delete role_name_;
148 #endif // STANDARD_COMPOSITION_RELATIONSHIPS_PACK_H
#define TEUCHOS_TEST_FOR_EXCEPTION(throw_exception_test, Exception, msg)
Thrown when the reference has not been set.