19 #include<utils/CmdInterface.hh> 20 #include<automata/SyncRulesLightLexer.hpp> 21 #include<automata/SyncRulesLightParser.hpp> 37 string description=
"Usage: dd-sync-info sync.rules [--help | --components | --events | --number | --connection-with-event event]\n\t Print information about the synchronization law in 'sync.rules\n\t\t'--help' print this usage message\n\t\t'--components' the list of component names involved in this law\n\t\t- '--events' the list of synchronized events\n\t\t'--number' the number of connections\n\t\t'--connection-with-event event' the list of events involved in a connection with 'event'";
52 void readParameters(
int argc,
char * argv[],
string & rulesFile,
string & eventLabel);
56 int main(
int argc,
char * argv[])
72 set<string> components;
73 list< set<string> > connections;
78 ifstream file(rulesFile);
79 Diades::Automata::SyncRulesLightLexer lexer(file);
80 Diades::Automata::SyncRulesLightParser parser(lexer);
81 parser.syncrules(components,connections);
86 string msg =
"Something unexpected happened: ";
94 for(
const string & comp : components)
105 for(
const set<string> & setEvts : connections)
107 events.insert(setEvts.begin(), setEvts.end());
111 for(
const string & evt : events)
119 cout << connections.size();
124 if(eventLabel.empty())
126 printError(
"No event label found after option --connection-with-event");
130 for(
const set<string> & setEvts : connections)
132 if(setEvts.find(eventLabel) != setEvts.end())
134 events.insert(setEvts.begin(), setEvts.end());
137 events.erase(eventLabel);
138 for(
const string & evt : events)
149 void readParameters(
int argc,
char * argv[],
string & rulesFile,
string & eventLabel)
159 while( index < argc )
162 if(getOption<Option>(argv[index],
options,currentOption))
164 if(
isSet[currentOption])
166 printError(
"The option '" +
options[currentOption] +
"' occurs at least twice.");
170 isSet[currentOption] =
true;
172 switch(currentOption)
197 getParameter<string>(argc,argv,index,eventLabel);
204 vector<string>::const_iterator it =
208 printError(
"Unrecognized file extension in file name: " +
string(argv[index]));
215 rulesFile = string(argv[index]);
vector< bool > isSet(numberOfOptions, false)
int main(int argc, char *argv[])
InputIterator getFileExtension(const std::basic_string< CharType, CharTraits > &fileName, InputIterator begin, InputIterator end)
vector< string > fileExtensions(numberOfFileExtensions)
vector< string > options(numberOfOptions)
unsigned numberOfFileExtensions
void readParameters(int argc, char *argv[], string &rulesFile, string &eventLabel)
void printError(string parameter, string message)
void printUsage(const po::options_description &desc)