45 _default_constraint(
"" )
73 map<string, string> props ;
79 string err =
"The specified command " + action
80 +
" is not a set context command" ;
86 def_name = props[
"name"] ;
87 if( def_name.empty() )
89 string err = action +
" command: definition name missing" ;
94 _str_cmd = (string)
"define " + def_name ;
96 def_space = props[
"space"] ;
97 if( !def_space.empty() )
103 int num_containers = 0 ;
107 xmlNode *child_node =
111 if( child_name ==
"constraint" )
114 _default_constraint = child_value ;
116 else if( child_name ==
"container" )
118 handle_container_element( action, child_node, child_value, props ) ;
121 else if( child_name ==
"aggregate" )
123 handle_aggregate_element( action, child_node, child_value, props ) ;
129 child_value.clear() ;
131 child_value, props ) ;
134 if( num_containers < 1 )
136 string err = action +
"The define element must contain at least "
137 +
"one container element" ;
143 vector<string>::iterator i = _containers.begin() ;
144 vector<string>::iterator e = _containers.end() ;
151 if( _constraints.size() )
155 map<string,string>::iterator ci = _constraints.begin() ;
156 map<string,string>::iterator ce = _constraints.end() ;
157 for( ; ci != ce; ci++ )
160 _str_cmd += (*ci).first +
".constraint=\"" + (*ci).second +
"\"" ;
162 string attrs = _attributes[(*ci).first] ;
165 _str_cmd +=
"," + (*ci).first +
".attributes=\"" + attrs +
"\"";
191 BESXMLDefineCommand::handle_container_element(
const string &action,
194 map<string,string> &props )
196 string name = props[
"name"] ;
199 string err = action +
" command: container element missing name prop" ;
203 _containers.push_back( name ) ;
205 string space = props[
"space"] ;
206 _stores[name] = space ;
208 bool have_constraint = false ;
209 bool have_attributes = false ;
214 map<string,string> child_props ;
215 xmlNode *child_node =
219 if( child_name ==
"constraint" )
221 if( child_props.size() )
223 string err = action +
" command: constraint element "
224 +
"should not contain properties" ;
227 if( child_value.empty() )
229 string err = action +
" command: attributes element "
233 if( have_constraint )
235 string err = action +
" command: container element "
236 +
"contains multiple constraint elements" ;
239 have_constraint = true ;
240 _constraints[name] = child_value ;
242 else if( child_name ==
"attributes" )
244 if( child_props.size() )
246 string err = action +
" command: attributes element "
247 +
"should not contain properties" ;
250 if( child_value.empty() )
252 string err = action +
" command: attributes element "
256 if( have_attributes )
258 string err = action +
" command: container element "
259 +
"contains multiple attributes elements" ;
262 have_attributes = true ;
263 _attributes[name] = child_value ;
269 child_value.clear() ;
271 child_value, props ) ;
287 BESXMLDefineCommand::handle_aggregate_element(
const string &action,
290 map<string,string> &props )
292 string handler = props[
"handler"] ;
293 string cmd = props[
"cmd"] ;
294 if( handler.empty() )
296 string err = action +
" command: must specify aggregation handler" ;
301 string err = action +
" command: must specify aggregation cmd" ;
307 _str_cmd +=
" aggregate using " + handler +
" by " + cmd ;
315 vector<string>::iterator i = _containers.begin() ;
316 vector<string>::iterator e = _containers.end() ;
323 string store = _stores[(*i)] ;
336 string s = (string)
"Could not find the container "
341 string constraint = _constraints[(*i)] ;
342 string attrs = _attributes[(*i)] ;
343 if( constraint.empty() ) constraint = _default_constraint ;
347 BESDEBUG(
"xml",
"define using container: " << endl << *c << endl ) ;
361 << (
void *)
this <<
")" << endl ;