DiaDes  0.1
DIAgnosis of Discrete-Event System
Functions | Variables
Project.cc File Reference

This file implements the dd-project command that is used to perform any kind of automata projection. More...

#include <cstdlib>
#include <iostream>
#include <fstream>
#include <regex>
#include <boost/program_options.hpp>
#include <diades/automata/experimental/AutFile.hh>
#include <diades/automata/experimental/DdAutFile.hh>
#include <diades/automata/experimental/Printer.hh>
#include <diades/automata/experimental/StateMachine.hh>
#include <diades/automata/experimental/Project.hh>
#include "../AutomataInterface.hh"
#include "diades/automata/experimental/DdAutFileDescriptor.hh"

Go to the source code of this file.

Functions

const string program ("dd-project")
 
void initialiseOptions (int argc, char *argv[], Poptions::options_description &desc, Poptions::variables_map &vm)
 
template<typename FsmType , typename Event >
bool getProjectedEvents (const FsmType &fsm, std::vector< Event > &events, std::vector< Event > &noevents, std::vector< Event > &projectedEvents)
 
size_t projectAut (const std::string &fileName, const std::string &output, std::vector< std::string > &events, std::vector< std::string > &noevents)
 
bool getProjectedEvents (const DdAutFsm &fsm, const std::vector< std::string > &events, const std::vector< std::string > &noevents, DdAutEventManager &eManager, std::vector< DdAutEventId > &projectedEvents)
 
size_t projectDdaut (const std::string &fileName, const std::string &output, std::vector< std::string > &events, std::vector< std::string > &noevents)
 
size_t projectFsm (const std::string &fileName, const std::string &output, std::vector< std::string > &events, std::vector< std::string > &noevents)
 
int main (int argc, char **argv)
 

Variables

FileSuffixes suffixes ({"aut", "ddaut"})
 

Detailed Description

This file implements the dd-project command that is used to perform any kind of automata projection.

Author
Yannick Pencolé
Date
10 June 2019, 22:05

Definition in file Project.cc.

Function Documentation

◆ getProjectedEvents() [1/2]

template<typename FsmType , typename Event >
bool getProjectedEvents ( const FsmType &  fsm,
std::vector< Event > &  events,
std::vector< Event > &  noevents,
std::vector< Event > &  projectedEvents 
)
Parameters
fsmThe loaded Fsm
eventsthe set of projected events ids declared in the command line
noeventsthe set of non-projected events ids declared in the command line
projectedEventsthe effective set of event ids to project in the fsm
Returns
true if projectedEvents exists. It might be empty. The result is false if the couple events/noevents is incompatible.

Definition at line 89 of file Project.cc.

Referenced by getProjectedEvents(), projectAut(), and projectDdaut().

◆ getProjectedEvents() [2/2]

bool getProjectedEvents ( const DdAutFsm fsm,
const std::vector< std::string > &  events,
const std::vector< std::string > &  noevents,
DdAutEventManager eManager,
std::vector< DdAutEventId > &  projectedEvents 
)
Parameters
fsmthe ddaut finite state machine to project
eventsthe set of event labels to project
noeventsthe set of event labels not to project
eManagerthe event manager of the initial fsm
projectedEventsthe set of event ids from eManager associated to the events to project
Returns
true if the set of projected events can be built. The result is false if the couple events/noevents is incompatible.

Definition at line 193 of file Project.cc.

References Diades::Automata::Experimental::EventManager< _Event, _EventId, NullEvent, NullEventId, Hash >::eventId(), getProjectedEvents(), and Diades::Automata::Experimental::EventManager< _Event, _EventId, NullEvent, NullEventId, Hash >::hasEvent().

◆ initialiseOptions()

void initialiseOptions ( int  argc,
char *  argv[],
Poptions::options_description &  desc,
Poptions::variables_map &  vm 
)

Initialise the options of the command present in the command line

Parameters
argc
argv
desc
vm

Definition at line 52 of file Project.cc.

References options().

Referenced by main().

◆ main()

int main ( int  argc,
char **  argv 
)

Main file of the dd-determine command

Parameters
argc
argv
Returns
success code (SUCCESS or ERROR_COMMAND_LINE)

Definition at line 349 of file Project.cc.

References initialiseOptions(), Diades::CmdInterface::printCommandLineError(), printUsage(), program(), and projectFsm().

◆ program()

const string program ( "dd-project"  )

Referenced by main().

◆ projectAut()

size_t projectAut ( const std::string &  fileName,
const std::string &  output,
std::vector< std::string > &  events,
std::vector< std::string > &  noevents 
)

Load the file (aut file) and make the automaton deterministic (low-level) and print on the output

Parameters
fileNameaut file to load
outputthe file to write (if empty, write on the standard output)
eventsthe set of events to project
noeventsthe set of events that must not be projected
Returns
success code (SUCCESS or ERROR_COMMAND_LINE) especially, check the consistency between events/noevents.

Definition at line 144 of file Project.cc.

References Diades::Automata::Experimental::fromAutFile(), getProjectedEvents(), Diades::CmdInterface::printCommandLineError(), Diades::Automata::project(), suffixes, toStream(), and Diades::CmdInterface::writeAut().

Referenced by projectFsm().

◆ projectDdaut()

size_t projectDdaut ( const std::string &  fileName,
const std::string &  output,
std::vector< std::string > &  events,
std::vector< std::string > &  noevents 
)

Load the file (ddaut file) and make the automaton deterministic and print on the output

Parameters
fileNameddaut file to load
outputthe file to write (if empty, write on the standard output, can be aut or ddaut file)
eventsthe set of events to project
noeventsthe set of events that must not be projected
Returns
success code (SUCCESS or ERROR_COMMAND_LINE) especially, check the consistency between events/noevents.

Definition at line 231 of file Project.cc.

References Diades::Automata::Experimental::DdAutFileDescriptor::acceptorBegin(), Diades::Automata::Experimental::DdAutFileDescriptor::acceptorEnd(), Diades::Automata::Experimental::faFromDescriptor(), Diades::Automata::Experimental::fsmFromDescriptor(), getProjectedEvents(), Diades::CmdInterface::printCommandLineError(), Diades::Automata::project(), Diades::Automata::Experimental::DdAutFileDescriptor::readStream(), suffixes, toStream(), Diades::CmdInterface::writeFiniteAutomaton(), and Diades::CmdInterface::writeFiniteStateMachine().

Referenced by projectFsm().

◆ projectFsm()

size_t projectFsm ( const std::string &  fileName,
const std::string &  output,
std::vector< std::string > &  events,
std::vector< std::string > &  noevents 
)

Load the file (aut file) and performs the projection based on the couple events/noevents

Parameters
fileNameaut file to load
outputthe file to write (if empty, write on the standard output)
eventsthe set of events to project
noeventsthe set of events that must not be projected
Returns
success code (SUCCESS or ERROR_COMMAND_LINE) especially, check the consistency between events/noevents.

Definition at line 316 of file Project.cc.

References ERROR_UNHANDLED_EXCEPTION, Diades::CmdInterface::FileSuffixes::match(), Diades::CmdInterface::printCommandLineError(), projectAut(), projectDdaut(), and suffixes.

Referenced by main().

Variable Documentation

◆ suffixes

FileSuffixes suffixes({"aut", "ddaut"})