tool/CommandXml.cpp
changeset 1826 ec6223c3b7ec
parent 1560 0ca50da62c52
child 1869 14f634f5b613
equal deleted inserted replaced
1825:65781b048a47 1826:ec6223c3b7ec
    31 #include <iomanip>
    31 #include <iomanip>
    32 #include <string.h>
    32 #include <string.h>
    33 using namespace std;
    33 using namespace std;
    34 
    34 
    35 #include "CommandXml.h"
    35 #include "CommandXml.h"
       
    36 #include "MasterDevice.h"
    36 
    37 
    37 /*****************************************************************************/
    38 /*****************************************************************************/
    38 
    39 
    39 CommandXml::CommandXml():
    40 CommandXml::CommandXml():
    40     Command("xml", "Generate slave information XML.")
    41     Command("xml", "Generate slave information XML.")
    66     return str.str();
    67     return str.str();
    67 }
    68 }
    68 
    69 
    69 /****************************************************************************/
    70 /****************************************************************************/
    70 
    71 
    71 void CommandXml::execute(MasterDevice &m, const StringVector &args)
    72 void CommandXml::execute(const StringVector &args)
    72 {
    73 {
    73     SlaveList slaves;
    74     SlaveList slaves;
    74     SlaveList::const_iterator si;
    75     SlaveList::const_iterator si;
    75 
    76 
    76     if (args.size()) {
    77     if (args.size()) {
    77         stringstream err;
    78         stringstream err;
    78         err << "'" << getName() << "' takes no arguments!";
    79         err << "'" << getName() << "' takes no arguments!";
    79         throwInvalidUsageException(err);
    80         throwInvalidUsageException(err);
    80     }
    81     }
    81 
    82 
       
    83     if (getMasterIndices().size() != 1) {
       
    84         stringstream err;
       
    85         err << getName() << " requires to select a single master!";
       
    86         throwInvalidUsageException(err);
       
    87     }
       
    88     MasterDevice m(getMasterIndices().front());
    82     m.open(MasterDevice::Read);
    89     m.open(MasterDevice::Read);
    83     slaves = selectedSlaves(m);
    90     slaves = selectedSlaves(m);
    84 
    91 
    85     cout << "<?xml version=\"1.0\" ?>" << endl;
    92     cout << "<?xml version=\"1.0\" ?>" << endl;
    86     if (slaves.size() > 1) {
    93     if (slaves.size() > 1) {