22 #ifndef _DescriptionScope_hxx_
23 #define _DescriptionScope_hxx_
54 typedef std::map<std::string, unsigned>
NamesMap;
59 std::string _scopeName;
76 template <
typename AttributeType>
77 void Add(
const std::string & name)
79 unsigned attributeIndex = _nameMap.size();
81 _nameMap.insert(std::make_pair(name,attributeIndex)).second;
82 CLAM_ASSERT(inserted,(
"Couldn't add attribute '"+_scopeName+
":"+name+
"', already present in the scope").c_str());
92 unsigned GetIndex(
const std::string & name)
const
94 NamesMap::const_iterator it = _nameMap.find(name);
96 (std::string()+
"Accessing an unexisting attribute '"+_scopeName+
"':'"+name+
"'").c_str());
105 NamesMap::const_iterator it = _nameMap.find(name);
106 if (it==_nameMap.end())
107 throw SchemaError(
"Accessing an unexisting attribute '"+_scopeName+
"':'"+name+
"'");
113 return _nameMap.size();
116 void *
Allocate(
unsigned attribute,
unsigned size)
const
118 return _attributes[attribute]->Allocate(size);
122 _attributes[attribute]->Deallocate(buffer);
125 template <
typename AttributeType>
126 void CheckType(
unsigned attributeIndex, AttributeType *)
const
128 _attributes[attributeIndex]->CheckType<AttributeType>();
134 "GetAttributeName: Using a wrong index to look up an attribute name");
136 return attribute->GetName();
140 return * _attributes[attribute];
147 #endif// _DescriptionScope_hxx_