44 _default_constraint(
"" )
71 map<string, string> props ;
77 string err =
"The specified command " + action
78 +
" is not a set context command" ;
84 def_name = props[
"name"] ;
85 if( def_name.empty() )
87 string err = action +
" command: definition name missing" ;
92 _str_cmd = (string)
"define " + def_name ;
94 int num_containers = 0 ;
102 if( child_name ==
"constraint" )
105 _default_constraint = child_value ;
107 else if( child_name ==
"container" )
109 handle_container_element( action, child_node, child_value, props ) ;
112 else if( child_name ==
"aggregate" )
114 handle_aggregate_element( action, child_node, child_value, props ) ;
120 child_value.clear() ;
122 child_value, props ) ;
125 if( num_containers < 1 )
127 string err = action +
"The define element must contain at least " 128 +
"one container element" ;
134 vector<string>::iterator i = _containers.begin() ;
135 vector<string>::iterator e = _containers.end() ;
142 if( _constraints.size() )
146 map<string,string>::iterator ci = _constraints.begin() ;
147 map<string,string>::iterator ce = _constraints.end() ;
148 for( ; ci != ce; ci++ )
151 _str_cmd += (*ci).first +
".constraint=\"" + (*ci).second +
"\"" ;
153 string attrs = _attributes[(*ci).first] ;
156 _str_cmd +=
"," + (*ci).first +
".attributes=\"" + attrs +
"\"";
182 BESXMLDefineCommand::handle_container_element(
const string &action,
185 map<string,string> &props )
187 string name = props[
"name"] ;
190 string err = action +
" command: container element missing name prop" ;
194 _containers.push_back( name ) ;
196 bool have_constraint = false ;
197 bool have_attributes = false ;
202 map<string,string> child_props ;
203 xmlNode *child_node =
207 if( child_name ==
"constraint" )
209 if( child_props.size() )
211 string err = action +
" command: constraint element " 212 +
"should not contain properties" ;
215 if( child_value.empty() )
217 string err = action +
" command: attributes element " 221 if( have_constraint )
223 string err = action +
" command: container element " 224 +
"contains multiple constraint elements" ;
227 have_constraint = true ;
228 _constraints[name] = child_value ;
230 else if( child_name ==
"attributes" )
232 if( child_props.size() )
234 string err = action +
" command: attributes element " 235 +
"should not contain properties" ;
238 if( child_value.empty() )
240 string err = action +
" command: attributes element " 244 if( have_attributes )
246 string err = action +
" command: container element " 247 +
"contains multiple attributes elements" ;
250 have_attributes = true ;
251 _attributes[name] = child_value ;
257 child_value.clear() ;
259 child_value, props ) ;
275 BESXMLDefineCommand::handle_aggregate_element(
const string &action,
278 map<string,string> &props )
280 string handler = props[
"handler"] ;
281 string cmd = props[
"cmd"] ;
282 if( handler.empty() )
284 string err = action +
" command: must specify aggregation handler" ;
289 string err = action +
" command: must specify aggregation cmd" ;
295 _str_cmd +=
" aggregate using " + handler +
" by " + cmd ;
303 vector<string>::iterator i = _containers.begin() ;
304 vector<string>::iterator e = _containers.end() ;
310 string constraint = _constraints[(*i)] ;
311 if( constraint.empty() ) constraint = _default_constraint ;
315 BESDEBUG(
"xml",
"define using container: " << endl << *d << endl ) ;
329 << (
void *)
this <<
")" << endl ;
static xmlNode * GetFirstChild(xmlNode *node, string &child_name, string &child_value, map< string, string > &child_props)
get the first element child node for the given node
virtual void dump(ostream &strm) const
dumps information about this object
BESXMLDefineCommand(const BESDataHandlerInterface &base_dhi)
virtual void dump(ostream &strm) const
dumps information about this object
list< BESContainer * > containers
static xmlNode * GetNextChild(xmlNode *child_node, string &next_name, string &next_value, map< string, string > &next_props)
get the next element child node after the given child node
static void GetNodeInfo(xmlNode *node, string &name, string &value, map< string, string > &props)
get the name, value if any, and any properties for the specified node
BESDataHandlerInterface _dhi
error thrown if there is a user syntax error in the request or any other user error ...
virtual void parse_request(xmlNode *node)
parse a show command.
virtual void set_response()
The request has been parsed, use the command action name to set the response handler.
virtual void prep_request()
prepare the define command by making sure the containers exist
static ostream & LMarg(ostream &strm)
void set_constraint(const string &s)
set the constraint for this container
static BESXMLCommand * CommandBuilder(const BESDataHandlerInterface &base_dhi)
void set_attributes(const string &attrs)
set desired attributes for this container
Structure storing information used by the BES to handle the request.
virtual BESContainer * look_for(const string &sym_name)
look for the specified container information in the list of persistent stores.
static BESContainerStorageList * TheList()
map< string, string > data
the map of string data that will be required for the current request.
#define BESDEBUG(x, y)
macro used to send debug information to the debug stream
A container is something that holds data.
string action
the response object requested, e.g.
#define DEFINE_RESPONSE_STR