Commit 9d5b2558 authored by Pascal Noisette's avatar Pascal Noisette
Browse files

Introduction de la structure de donnée dans le Parser : bouchon pour fournir...

Introduction de la structure de donnée dans le Parser : bouchon pour fournir une réponse aux appels à la structure
parent e5a84038
#include "Date.hpp"
Date::Date(std::string& s){
me = s;
}
std::string &Date::tostring() {
return me;
}
#ifndef DATE_H
#define DATE_H
#include <iostream>
/*!
*
* \file Trace.hpp
* \author NOISETTE
* \brief Bouchon
*
*
*
*/
class Date{
std::string me;
public:
Date(std::string&);
std::string &tostring();
};
#endif
#include "Name.hpp"
Name::Name(std::string& s){
me = s;
}
std::string &Name::tostring() {
return me;
}
#ifndef NAME
#define NAME
#include <iostream>
/*!
*
* \file Trace.hpp
* \author NOISETTE
* \brief Bouchon
*
*
*
*/
class Name{
std::string me;
public:
Name(std::string&);
std::string &Name::tostring();
};
#endif
#include "String.hpp"
String::String(std::string& s){
me = s;
}
std::string &String::tostring() {
return me;
}
#ifndef STRING
#define STRING
#include <iostream>
/*!
*
* \file Trace.hpp
* \author NOISETTE
* \brief Bouchon
*
*
*
*/
class String{
std::string me;
public:
String(std::string&);
std::string &tostring();
};
#endif
/*!
*
* \file Trace.hpp
* \author NOISETTE
* \brief Bouchon
*
*
*
*/
#include "Trace.hpp"
#include <iostream>
void Trace::define_container_type(String container_type_parent, Name alias){
std::cout<<"define_container_type "<< container_type_parent.tostring() << " " << alias.tostring()<<std::endl;
}
Trace Trace::create_container(Date time, Name alias, String container, String parent){
std::cout<<"create_container "<< time.tostring() << alias.tostring()<<std::endl;
}
void Trace::destroy_container(Date time, Name alias, String type){
std::cout<<"destroy_container " << time.tostring() << " " << alias.tostring() << " " << type.tostring() << std::endl;
}
void Trace::define_event_type(Name alias, String container_type){
std::cout<<"define_event_type " << alias.tostring()<< " " << container_type.tostring()<<std::endl;
}
void Trace::define_state_type(Name alias, String container_type){
std::cout<<"define_state_type " << alias.tostring() << " " << container_type.tostring() << std::endl;
}
void Trace::define_variable_type(Name alias, String container_type){
std::cout<<"define_variable_type " << alias.tostring() << " " << container_type.tostring() << std::endl;
}
void Trace::define_link_type(Name alias, String container_type_ancestor, String type_container_source, String type_container_destination){
std::cout<<"define_link_type "<< alias.tostring() << " " << container_type_ancestor.tostring() << " " << type_container_source.tostring() << " " << type_container_destination.tostring()<< std::endl;
}
void Trace::define_entity_value(Name alias, String entity_type){
std::cout<<"define_entity_value " << alias.tostring() << " " << entity_type.tostring() << std::endl;
}
void Trace::set_state(Date time, String type, String container, String value){
std::cout<<"set_state " << time.tostring() << " " << type.tostring() << " " << container.tostring() << " " << value.tostring() << std::endl;
}
void Trace::push_state(Date time, String type, String container, String value){
std::cout<<"push_state " << time.tostring() << " " << type.tostring() << " " << container.tostring() << " " << value.tostring() << std::endl;
}
void Trace::pop_state(Date time, String type, String container){
std::cout<<"pop_state " << time.tostring() << " " << type.tostring() << " " << container.tostring() << " " << std::endl;
}
void Trace::new_event(Date time, String type, String container, String value){
std::cout<<"new_event " << time.tostring() << " " << type.tostring() << " " << container.tostring() << " " << value.tostring() << std::endl;
}
void Trace::set_variable(Date time, String type, String container, double value){
std::cout<<"set_variable " << time.tostring() << " " << type.tostring() << " " << container.tostring() << " " << value << std::endl;
}
void add_variable(Date time, String type, String container, double value){
std::cout<<"add_variable " << time.tostring() << " " << type.tostring() << " " << container.tostring() << " " << value << std::endl;
}
void Trace::sub_variable(Date time, String type, String container, double value){
std::cout<<"sub_variable " << time.tostring() << " " << type.tostring() << " " << container.tostring() << " " << value << std::endl;
}
void Trace::start_link(Date time, String type, String container, String src, String value, String key){
std::cout<<"start_link " << time.tostring() << " " << type.tostring() << " " << container.tostring() << " " << src.tostring() << " " << value.tostring() << " " << key.tostring() << std::endl;
}
void Trace::end_link(Date time, String type, String container, String dest, String value, String key){
std::cout<<"end_link "<< time.tostring() << " " << type.tostring() << " " << container.tostring() << " " << value.tostring() << " " << key.tostring() << std::endl;
}
#ifndef TRACE
#define TRACE
#include "String.hpp"
#include "Name.hpp"
#include "Date.hpp"
/*!
*
* \file Trace.hpp
* \author NOISETTE
* \brief Bouchon
*
*
*
*/
class Trace{
public :
/*!
*
*\fn define_container_type()
*\brief This function is to define a container type
*
*\param String : the type of his parent container
* Name : an object that can contain a name, an alias or both
*/
void define_container_type(String container_type_parent, Name alias);
/*!
*
*\fn create_container()
*\brief This function is to create a container
*
*
*\param
* Date :
* Name : an object that can contain a name, an alias or both
* String : the type of the container
* String : the parent of the container
*/
Trace create_container(Date time, Name alias, String container, String parent);
/*!
*
*\fn destroy_container()
*\brief This function is to destroy a container
*
*\param
* Date :
* Name : an object that can contain a name, an alias or both
* String : the type of the container
*/
void destroy_container(Date time, Name alias, String type);
/*!
*
*\fn define_event_type()
*\brief This function is to define a type of event
*
*\param
* Name : an object that can contain a name, an alias or both
* String : the type of the container
*/
void define_event_type(Name alias, String container_type);
/*!
*
*\fn define_state_type()
*\brief This function is to define a type of state
*
*\param
* Name : an object that can contain a name, an alias or both
* String : the type of the container
*
*/
void define_state_type(Name alias, String container_type);
/*!
*
*\fn define_variable_type()
*\brief This function is to define a type of variable
*
*\param
* Name : an object that can contain a name, an alias or both
* String : the type of the container
*
*/
void define_variable_type(Name alias, String container_type);
/*!
*
*\fn define_link_type()
*\brief This function is to define a type of link
*
*\param
* Name : an object that can contain a name, an alias or both
* String : the type of the container that is the common ancestor of both container
* String : the type of the container where the link starts
* String : the type of the container where the link goes
*
*/
void define_link_type(Name alias, String container_type_ancestor, String type_container_source, String type_container_destination);
/*!
*
*\fn define_entity_value()
*\brief This function is to define_entity_value
*
*\param
* Name : an object that can contain a name, an alias or both
* String : the type of the entity
*
*/
void define_entity_value(Name alias, String entity_type);
/*!
*
*\fn set_state()
*\brief This function is to set a state
*
*\param
* Date :
* String : the type of the entity
* String : the container
* String : the new value of the state
*
*/
void set_state(Date time, String type, String container, String value);
/*!
*
*\fn push_state()
*\brief This function is to push a state on the stack
*
*\param
* Date :
* String : the type of the entity
* String : the container
* String : the new value of the state
*
*/
void push_state(Date time, String type, String container, String value);
/*!
*
*\fn pop_state()
*\brief This function is to pop a state from the stack
*
*\param
* Date :
* String : the type of the entity
* String : the container
*
*/
void pop_state(Date time, String type, String container);
/*!
*
*\fn new_event()
*\brief This function is to create a new event
*
*\param
* Date :
* String : the type of the entity
* String : the container
* String : the value of the event
*
*/
void new_event(Date time, String type, String container, String value);
/*!
*
*\fn set_variable()
*\brief This function is to set a value to the variable
*
*\param
* Date :
* String : the type of the entity
* String : the container
* double : the value of the variable
*/
void set_variable(Date time, String type, String container, double value);
/*!
*
*\fn add_variable()
*\brief This function is to add a new variable
*
*\param
* Date :
* String : the type of the entity
* String : the container
* double : the value of the variable
*
*/
void add_variable(Date time, String type, String container, double value);
/*!
*
*\fn sub_variable()
*\brief This function is to substract a value to the variable
*
*\param
* Date :
* String : the type of the entity
* String : the container
* double : the value of the variable
*
*/
void sub_variable(Date time, String type, String container, double value);
/*!
*
*\fn start_link()
*\brief This function is to start a link
*
*\param
* Date :
* String : the type of the entity
* String : the container
* String : the source of the link
* String : the value of the variable
*
*/
void start_link(Date time, String type, String container, String src, String value, String key);
/*!
*
*\fn end_link()
*\brief This function is to end a link
*
*\param
* Date :
* String : the type of the entity
* String : the container
* String : the destination of the link
* String : the value of the variable
*
*/
void end_link(Date time, String type, String container, String dest, String value, String key);
};//end class
#endif
......@@ -4,10 +4,7 @@
#include <vector>
#include <iostream>
#define INTEGER 0
#define COLOR 1
#define STRING 2
#define DATE 3
/*! \class Definition Definition.hpp "../parser/src/Definition.hpp"
* Contains the definition of a definition.
......@@ -20,7 +17,7 @@ class Definition{
std::string _name;
std::string _type;
};
std::vector<field> _compulsory;
std::vector<field> _optional;
......
......@@ -7,8 +7,8 @@
*
*/
class ParserEventDecoder{
class ParserEventDecoder{
private:
/*!
*
......@@ -18,11 +18,11 @@ private:
*\param String : type ("Name", "Color"...)
* String : value ("integer","string")
*/
Type convert(String type, String value);
public:
void sort_definition(Definition,ligne);
void sort_definition(Definition,Line);
};
......
......@@ -5,7 +5,7 @@ using namespace std;
void ParserPaje::parse(string filename, Trace &trace){
// We open the file in read only
ifstream file(filename.c_str(), ios::in);
// We check if the file has been opened
if(!file){
cerr << "Unable to open : " << filename << endl;
......@@ -24,10 +24,10 @@ void ParserPaje::parse(string filename, Trace &trace){
}
else{
// We have a new event
_parser_event_decoder;
trace;
//_parser_event_decoder;
//trace;
}
}
file.close();
}
......@@ -2,7 +2,7 @@
#define PARSERPAJE_HPP
#include <string>
#include "../../structureDonnee/trace.hpp"
#include "../Bouchon/trace.hpp"
#include "ParserDefinitionDecoder.hpp"
#include "ParserEventDecoder.hpp"
......@@ -10,21 +10,21 @@
*
* \class ParserPaje
* \brief parse the format of Paje.
*
*
*/
class ParserPaje : public Parser {
class ParserPaje {
private:
ParserEventDecoder _parser_event_decoder;
ParserDefinitionDecoder _parser_definition_decoder;
public:
/*!
* \fn parse(std::string filename)
* \param : the name of the file to parse
* \param : the structure of data to fill
*/
void parse(std::string filename, Trace &trace);
void parse(std::string filename, Trace &trace);
};
#endif // PARSERPAJE_HPP
......
......@@ -21,16 +21,16 @@ int main(int argc, char **argv){
}
}
int nb_def = parser->definitions_number();
for (it = .begin() ; it != mymap.end() ; it ++){
Definition def = parser->get_definition(it);
def.print();
}
for(int i = 0 ; i < nb_def ; i ++){
Definition def = parser->get_definition(i);
def.print();
}
// int nb_def = parser->definitions_number();
// for (it = .begin() ; it != mymap.end() ; it ++){
// Definition def = parser->get_definition(it);
// def.print();
// }
//
// for(int i = 0 ; i < nb_def ; i ++){
// Definition def = parser->get_definition(i);
// def.print();
// }
delete parser;
return EXIT_SUCCESS;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment