Tries to send a dim command according to the arguments. The command given is evaluated according to the available format string.
- Parameters
-
server | The name of the server to which the command should be send, e.g. DRIVE |
str | Command and data, eg "TRACK 12.5 13.8" |
lout | the ostream to which errors and debug output is redirected |
- Exceptions
-
runtime_error | if the server or command was not found, or if the format associated with the command could not be properly parsed, or if the command could not successfully be emitted. |
Definition at line 645 of file DimServiceInfoList.cc.
References Converter::GetVector(), kBlue, DimClient::sendCommandNB(), t, and Tools::Trim().
650 size_t p0 =
str.find_first_of(
' ');
651 if (p0==string::npos)
655 const string name =
str.substr(0, p0);
658 const string cmd = server +
'/' + name;
660 const ServiceList::const_iterator m =
fServiceList.find(server);
662 throw runtime_error(
"Unkown server '"+server+
"'");
664 const TypeList &services = m->second.first;
666 const TypeList::const_iterator
t = services.find(name);
667 if (t==services.end())
668 throw runtime_error(
"Command '"+name+
"' not known on server '"+server+
"'");
670 if (!t->second.second)
671 throw runtime_error(
"'"+server+
"/"+name+
" not a command.");
674 const string fmt = t->second.first;
688 throw runtime_error(
"Couldn't properly parse the format... ignored.");
691 lout <<
kBlue << cmd;
693 const vector<char> v = conv.GetVector(
str.substr(p0));
695 lout <<
kBlue <<
" [" << v.size() <<
"]" << endl;
std::map< const std::string, ServiceType > TypeList
ServiceList fServiceList
A map storing the service description to retrieve all informations.
static void sendCommandNB(const char *name, int data)
A compiler for the DIM data format string.