Skip to content
Snippets Groups Projects
Commit 219dc02d authored by Jaime Arias's avatar Jaime Arias
Browse files

removing std namespace from headers

parent 358647ec
No related branches found
No related tags found
No related merge requests found
Showing
with 114 additions and 60 deletions
...@@ -2,3 +2,9 @@ ...@@ -2,3 +2,9 @@
- Jaime ARIAS (arias@lipn.univ-paris13.fr) - Jaime ARIAS (arias@lipn.univ-paris13.fr)
- Giann Karlo AGUIRRE SAMBONÍ (giannkas1@gmail.com) - Giann Karlo AGUIRRE SAMBONÍ (giannkas1@gmail.com)
The development of this tool has been support by:
- PICS CNRS Project PARTIES (2019)
- PHC Van Gogh Project PAMPAS (2019)
- BQR Project AMOJAS (2018)
...@@ -18,6 +18,11 @@ ...@@ -18,6 +18,11 @@
* @defgroup eamas Extended Asynchronous Multi-Agents Systems * @defgroup eamas Extended Asynchronous Multi-Agents Systems
*/ */
/**
* @defgroup eamas_action EAMAS' Actions
* @ingroup eamas
*/
/** /**
* @defgroup adt2amas Translator ADTree into EAMAS * @defgroup adt2amas Translator ADTree into EAMAS
*/ */
#ifndef ACTION_HPP #ifndef ACTION_HPP
#define ACTION_HPP #define ACTION_HPP
#include <iostream> #include <string>
#include <vector> #include <vector>
// #include "amas_visitor.hpp"
// class AMASVisitor;
//! \ingroup eamas_action
//! Action entity, associated to a transition to represent either a //! Action entity, associated to a transition to represent either a
//! Synchronization or a Label implementations. //! Synchronization or a Label implementations.
/*! Action is an abstract class since it has at least one pure virtual /*! Action is an abstract class since it has at least one pure virtual
...@@ -20,8 +18,6 @@ class Action { ...@@ -20,8 +18,6 @@ class Action {
//! A pure virtual member. //! A pure virtual member.
virtual std::string get_info() = 0; virtual std::string get_info() = 0;
// virtual void accept(AMASVisitor &visitor) = 0;
//! A pure virtual member. //! A pure virtual member.
virtual std::vector<std::string> get_info_vector() = 0; virtual std::vector<std::string> get_info_vector() = 0;
}; };
......
#ifndef AUTOMATA_HPP #ifndef AUTOMATA_HPP
#define AUTOMATA_HPP #define AUTOMATA_HPP
#include <set>
#include <string>
#include <vector>
#include "automaton.hpp" #include "automaton.hpp"
#include "channel.hpp" #include "channel.hpp"
#include "parser/amas_visitor.hpp" #include "parser/amas_visitor.hpp"
...@@ -9,6 +12,8 @@ class Automaton; ...@@ -9,6 +12,8 @@ class Automaton;
class AMASVisitor; class AMASVisitor;
/** /**
* \ingroup eamas
*
* Automata entity, a bunch of automaton and channels to synchronize them. * Automata entity, a bunch of automaton and channels to synchronize them.
* Basically, it is a class to model and control a system which has several * Basically, it is a class to model and control a system which has several
* agents (Automaton) and channels. The former communicate and synchronize * agents (Automaton) and channels. The former communicate and synchronize
...@@ -22,7 +27,7 @@ class Automata { ...@@ -22,7 +27,7 @@ class Automata {
ids must be unique and can not exist twice same Automaton instances in ids must be unique and can not exist twice same Automaton instances in
Automata. Automata.
*/ */
set<int> automaton_ids_; std::set<int> automaton_ids_;
//! A private attribute of set type to collect integers. //! A private attribute of set type to collect integers.
/*! /*!
...@@ -30,21 +35,21 @@ class Automata { ...@@ -30,21 +35,21 @@ class Automata {
ids must be unique and can not exist twice same Channel instances in ids must be unique and can not exist twice same Channel instances in
Automata. Automata.
*/ */
set<int> channel_ids_; std::set<int> channel_ids_;
//! A private attribute of vector type to collect Automaton pointers. //! A private attribute of vector type to collect Automaton pointers.
/*! /*!
It is used to save Automaton pointers which are in the Automata. The It is used to save Automaton pointers which are in the Automata. The
pointers here must be correlated with ids saved in automaton_ids_. pointers here must be correlated with ids saved in automaton_ids_.
*/ */
vector<Automaton *> vector_automaton_; std::vector<Automaton *> vector_automaton_;
//! A private attribute of vector type to collect Channel pointers. //! A private attribute of vector type to collect Channel pointers.
/*! /*!
It is used to save Channel pointers which are in the Automata. The It is used to save Channel pointers which are in the Automata. The
pointers here must be correlated with ids saved in channel_ids_. pointers here must be correlated with ids saved in channel_ids_.
*/ */
vector<Channel *> channels_; std::vector<Channel *> channels_;
public: public:
//! Automata constructor. //! Automata constructor.
...@@ -53,6 +58,7 @@ An instance of Automata is created empty and following, it is possible to add ...@@ -53,6 +58,7 @@ An instance of Automata is created empty and following, it is possible to add
Automaton and Channel instances. Automaton and Channel instances.
*/ */
Automata(); Automata();
//! Action destructor. //! Action destructor.
~Automata(); ~Automata();
...@@ -63,7 +69,7 @@ Automaton and Channel instances. ...@@ -63,7 +69,7 @@ Automaton and Channel instances.
Member part of getters. Member part of getters.
\return A vector of type Automaton pointers. \return A vector of type Automaton pointers.
*/ */
vector<Automaton *> get_vector_automaton(); std::vector<Automaton *> get_vector_automaton();
//! A public method to get ids of Automaton instances associated with this //! A public method to get ids of Automaton instances associated with this
//! Automata instance. //! Automata instance.
...@@ -72,14 +78,14 @@ Automaton and Channel instances. ...@@ -72,14 +78,14 @@ Automaton and Channel instances.
\return A set of type int which are Automaton ids associated with this \return A set of type int which are Automaton ids associated with this
Automata instance. Automata instance.
*/ */
set<int> get_automaton_ids(); std::set<int> get_automaton_ids();
//! A public method to get vector pointers of Channel instances. //! A public method to get vector pointers of Channel instances.
/*! /*!
Member part of getters. Member part of getters.
\return A vector of type Channel pointers. \return A vector of type Channel pointers.
*/ */
vector<Channel *> get_channels(); std::vector<Channel *> get_channels();
//! A public method to get a information type of string. //! A public method to get a information type of string.
/*! /*!
...@@ -87,8 +93,12 @@ Automaton and Channel instances. ...@@ -87,8 +93,12 @@ Automaton and Channel instances.
\return A string which contain information about an Automata instance, \return A string which contain information about an Automata instance,
their Automaton and Channel instances. their Automaton and Channel instances.
*/ */
string get_info(); std::string get_info();
//! A public method implementing the visitor pattern
/*!
@param visitor is a visitor instance
*/
void accept(AMASVisitor &visitor); void accept(AMASVisitor &visitor);
/* Sets */ /* Sets */
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
#define AUTOMATON_HPP #define AUTOMATON_HPP
#include <set> #include <set>
#include <string>
#include <vector> #include <vector>
#include "action.hpp" #include "action.hpp"
#include "parser/amas_visitor.hpp" #include "parser/amas_visitor.hpp"
...@@ -13,6 +14,7 @@ class AMASVisitor; ...@@ -13,6 +14,7 @@ class AMASVisitor;
class State; class State;
class Transition; class Transition;
//! \ingroup eamas
//! Automaton entity, compose by states and transitions to connect them. //! Automaton entity, compose by states and transitions to connect them.
/*! /*!
A class to model an agent which is an abstract machine with states and A class to model an agent which is an abstract machine with states and
...@@ -49,7 +51,7 @@ class Automaton { ...@@ -49,7 +51,7 @@ class Automaton {
It is used to save State ids to take advantage of set definition since ids It is used to save State ids to take advantage of set definition since ids
must be unique and can not exist twice same State instances in Automaton. must be unique and can not exist twice same State instances in Automaton.
*/ */
set<int> state_ids_; std::set<int> state_ids_;
//! A private attribute of set type to collect integers. //! A private attribute of set type to collect integers.
/*! /*!
...@@ -57,21 +59,21 @@ class Automaton { ...@@ -57,21 +59,21 @@ class Automaton {
since ids must be unique and can not exist twice same Transition instances since ids must be unique and can not exist twice same Transition instances
in Automaton. in Automaton.
*/ */
set<int> transition_ids_; std::set<int> transition_ids_;
//! A private attribute of vector type to collect State pointers. //! A private attribute of vector type to collect State pointers.
/*! /*!
It is used to save State pointers which are in the Automaton. The pointers It is used to save State pointers which are in the Automaton. The pointers
here must be correlated with ids saved in state_ids_. here must be correlated with ids saved in state_ids_.
*/ */
vector<State *> states_; std::vector<State *> states_;
//! A private attribute of vector type to collect Transition pointers. //! A private attribute of vector type to collect Transition pointers.
/*! /*!
It is used to save Transition pointers which are in the Automaton. The It is used to save Transition pointers which are in the Automaton. The
pointers here must be correlated with ids saved in transition_ids_. pointers here must be correlated with ids saved in transition_ids_.
*/ */
vector<Transition *> transitions_; std::vector<Transition *> transitions_;
//! A private method to remove a Transition instance to an Automaton instance //! A private method to remove a Transition instance to an Automaton instance
//! because removing a state. //! because removing a state.
...@@ -105,6 +107,7 @@ class Automaton { ...@@ -105,6 +107,7 @@ class Automaton {
of this Automaton instance. of this Automaton instance.
*/ */
Automaton(State *initial_state); Automaton(State *initial_state);
//! Automaton destructor. //! Automaton destructor.
/*! /*!
It deletes their pointer to initial_state_. It deletes their pointer to initial_state_.
...@@ -133,7 +136,7 @@ class Automaton { ...@@ -133,7 +136,7 @@ class Automaton {
\return A set of type int which are State ids associated with this \return A set of type int which are State ids associated with this
Automaton instance. Automaton instance.
*/ */
set<int> get_state_ids(); std::set<int> get_state_ids();
//! A public method to get ids of Transition instances associated with this //! A public method to get ids of Transition instances associated with this
//! Automaton instance. //! Automaton instance.
...@@ -142,21 +145,21 @@ class Automaton { ...@@ -142,21 +145,21 @@ class Automaton {
\return A set of type int which are Transition ids associated with this \return A set of type int which are Transition ids associated with this
Automaton instance. Automaton instance.
*/ */
set<int> get_transition_ids(); std::set<int> get_transition_ids();
//! A public method to get vector pointers of State instances. //! A public method to get vector pointers of State instances.
/*! /*!
Member part of getters. Member part of getters.
\return A vector of type State pointers. \return A vector of type State pointers.
*/ */
vector<State *> get_states(); std::vector<State *> get_states();
//! A public method to get vector pointers of Transition instances. //! A public method to get vector pointers of Transition instances.
/*! /*!
Member part of getters. Member part of getters.
\return A vector of type Transition pointers. \return A vector of type Transition pointers.
*/ */
vector<Transition *> get_transitions(); std::vector<Transition *> get_transitions();
//! A public method to get a information type of string. //! A public method to get a information type of string.
/*! /*!
...@@ -165,8 +168,12 @@ class Automaton { ...@@ -165,8 +168,12 @@ class Automaton {
their State and Transition instances. Indentation applied for each their State and Transition instances. Indentation applied for each
Transition instance associated with a particular State. Transition instance associated with a particular State.
*/ */
string get_info(); std::string get_info();
//! A public method implementing the visitor pattern
/*!
@param visitor is a visitor instance
*/
void accept(AMASVisitor &visitor); void accept(AMASVisitor &visitor);
/* Sets */ /* Sets */
...@@ -196,7 +203,7 @@ class Automaton { ...@@ -196,7 +203,7 @@ class Automaton {
same entries. same entries.
*/ */
void add_transition(State *source_state, State *destination_state, void add_transition(State *source_state, State *destination_state,
Action *action, vector<Update *> updates = {}); Action *action, std::vector<Update *> updates = {});
//! A public method to add an State instance to an Automaton instance. //! A public method to add an State instance to an Automaton instance.
/*! /*!
......
#include "channel.hpp" #include "channel.hpp"
using namespace std;
Channel::Channel(string name) : name_(name) { Channel::Channel(string name) : name_(name) {
++current_id; ++current_id;
id = current_id; id = current_id;
......
#ifndef CHANNEL_HPP #ifndef CHANNEL_HPP
#define CHANNEL_HPP #define CHANNEL_HPP
#include <iostream> #include <string>
using namespace std;
/** /**
* @ingroup eamas_action
*
* Channel entity, part of Automata used to synchronize Automaton. * Channel entity, part of Automata used to synchronize Automaton.
* This class is used to allow a way where several agents can synchronize (Send * This class is used to allow a way where several agents can synchronize (Send
* or Receive) regard to name Channel. It has an unique id number. * or Receive) regard to name Channel. It has an unique id number.
...@@ -31,7 +31,7 @@ class Channel { ...@@ -31,7 +31,7 @@ class Channel {
/** /**
* A private attribute of string type to save a Channel name instance. * A private attribute of string type to save a Channel name instance.
*/ */
string name_; std::string name_;
public: public:
/** /**
...@@ -40,7 +40,7 @@ class Channel { ...@@ -40,7 +40,7 @@ class Channel {
* *
* @param name is a default argument which if not passed, is an empty string. * @param name is a default argument which if not passed, is an empty string.
*/ */
Channel(string name = ""); Channel(std::string name = "");
/** /**
* Channel destructor. * Channel destructor.
*/ */
...@@ -59,7 +59,7 @@ class Channel { ...@@ -59,7 +59,7 @@ class Channel {
* *
* @return A string type corresponding to the name of a Channel instance. * @return A string type corresponding to the name of a Channel instance.
*/ */
string get_name(); std::string get_name();
/** /**
* A public method to get the info of a Channel instance. * A public method to get the info of a Channel instance.
...@@ -67,7 +67,7 @@ class Channel { ...@@ -67,7 +67,7 @@ class Channel {
* @return A string type corresponding to the word (Channel) concatenate with * @return A string type corresponding to the word (Channel) concatenate with
* id number and name of a Channel instance. * id number and name of a Channel instance.
*/ */
string get_info(); std::string get_info();
/* Sets */ /* Sets */
...@@ -76,6 +76,6 @@ class Channel { ...@@ -76,6 +76,6 @@ class Channel {
* *
* @param name is a string for the new name to be assigned in name_ attribute. * @param name is a string for the new name to be assigned in name_ attribute.
*/ */
void set_name(string name); void set_name(std::string name);
}; };
#endif #endif
#include "label.hpp" #include "label.hpp"
using namespace std;
Label::Label(string name) : name_(name) {} Label::Label(string name) : name_(name) {}
Label::~Label() {} Label::~Label() {}
......
...@@ -9,6 +9,8 @@ ...@@ -9,6 +9,8 @@
class AMASVisitor; class AMASVisitor;
/** /**
* @ingroup eamas_action
*
* Label entity, an Action which does not synchronize. * Label entity, an Action which does not synchronize.
* *
* It is an implementation for Action interface and set a name for an action * It is an implementation for Action interface and set a name for an action
...@@ -29,6 +31,7 @@ class Label : public Action { ...@@ -29,6 +31,7 @@ class Label : public Action {
* @param name is a default argument which if not passed, is an empty string. * @param name is a default argument which if not passed, is an empty string.
*/ */
Label(std::string name = ""); Label(std::string name = "");
/** /**
* Label destructor. * Label destructor.
*/ */
...@@ -50,6 +53,11 @@ class Label : public Action { ...@@ -50,6 +53,11 @@ class Label : public Action {
*/ */
std::string get_info(); std::string get_info();
/**
* A public method implementing the visitor pattern
*
* @param visitor is a visitor instance
*/
void accept(AMASVisitor &visitor); void accept(AMASVisitor &visitor);
/** /**
......
#include "state.hpp" #include "state.hpp"
#include <string> #include <string>
#include <vector>
using namespace std; using namespace std;
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
#define STATE_HPP #define STATE_HPP
#include <string> #include <string>
#include <vector>
#include "parser/amas_visitor.hpp" #include "parser/amas_visitor.hpp"
#include "state_type.hpp" #include "state_type.hpp"
#include "transition.hpp" #include "transition.hpp"
...@@ -41,7 +42,7 @@ class State { ...@@ -41,7 +42,7 @@ class State {
* A private attribute of vector type to collect Transition pointers. * A private attribute of vector type to collect Transition pointers.
* It is used to save Transition pointers associated with a State instance. * It is used to save Transition pointers associated with a State instance.
*/ */
vector<Transition *> transitions_; std::vector<Transition *> transitions_;
public: public:
/** /**
...@@ -79,7 +80,7 @@ class State { ...@@ -79,7 +80,7 @@ class State {
* @return A vector of type Transition pointers, which are associated to a * @return A vector of type Transition pointers, which are associated to a
* State instance. * State instance.
*/ */
vector<Transition *> get_transitions(); std::vector<Transition *> get_transitions();
/** /**
* A public method to get the info of a State instance. * A public method to get the info of a State instance.
...@@ -116,6 +117,6 @@ class State { ...@@ -116,6 +117,6 @@ class State {
* @param transitions is a vector for the new transition pointers to be * @param transitions is a vector for the new transition pointers to be
* assigned in transitions_ attribute. * assigned in transitions_ attribute.
*/ */
void set_transitions(vector<Transition *> transitions); void set_transitions(std::vector<Transition *> transitions);
}; };
#endif #endif
#include "state_type.hpp" #include "state_type.hpp"
using namespace std;
string to_string(StateType st) { string to_string(StateType st) {
string _st = ""; string _st = "";
switch (st) { switch (st) {
......
#ifndef STATE_TYPE_HPP #ifndef STATE_TYPE_HPP
#define STATE_TYPE_HPP #define STATE_TYPE_HPP
#include <iostream>
#include <string> #include <string>
using namespace std;
/** /**
* @ingroup eamas
*
* StateType enum class. * StateType enum class.
* *
* by definition there are three types of States: initial, normal and accepted. * by definition there are three types of States: initial, normal and accepted.
*/ */
enum class StateType { enum class StateType { Normal, Initial, Accepted };
Normal, // 0
Initial, // 1
Accepted // 2
};
// methods // methods
...@@ -26,6 +21,6 @@ enum class StateType { ...@@ -26,6 +21,6 @@ enum class StateType {
* @return A string type corresponding to the mapping function implemented for * @return A string type corresponding to the mapping function implemented for
* the st argument. * the st argument.
*/ */
string to_string(StateType st); std::string to_string(StateType st);
#endif #endif
#include "synchronization.hpp" #include "synchronization.hpp"
#include <bits/stdc++.h>
using namespace std;
Synchronization::Synchronization(SynchronizationType synchronization_type, Synchronization::Synchronization(SynchronizationType synchronization_type,
Channel *channel) Channel *channel)
......
#ifndef SYNCHRONIZATION_HPP #ifndef SYNCHRONIZATION_HPP
#define SYNCHRONIZATION_HPP #define SYNCHRONIZATION_HPP
#include <string>
#include <vector>
#include "action.hpp" #include "action.hpp"
#include "channel.hpp" #include "channel.hpp"
#include "parser/amas_visitor.hpp" #include "parser/amas_visitor.hpp"
...@@ -9,6 +11,8 @@ ...@@ -9,6 +11,8 @@
class AMASVisitor; class AMASVisitor;
/** /**
* @ingroup eamas_action
*
* Synchronization entity, an action used to synchronize automaton. * Synchronization entity, an action used to synchronize automaton.
* *
* It is an implementation for Action interface and set a type to synchronize * It is an implementation for Action interface and set a type to synchronize
...@@ -41,6 +45,7 @@ class Synchronization : public Action { ...@@ -41,6 +45,7 @@ class Synchronization : public Action {
Synchronization( Synchronization(
SynchronizationType synchronization_type = SynchronizationType::Send, SynchronizationType synchronization_type = SynchronizationType::Send,
Channel *channel = nullptr); Channel *channel = nullptr);
/** /**
* Channel destructor. * Channel destructor.
*/ */
...@@ -69,8 +74,13 @@ class Synchronization : public Action { ...@@ -69,8 +74,13 @@ class Synchronization : public Action {
* Synchronization type concatenate the name of the Channel instance * Synchronization type concatenate the name of the Channel instance
* associated. * associated.
*/ */
string get_info(); std::string get_info();
/**
* A public method implementing the visitor pattern
*
* @param visitor is a visitor instance
*/
void accept(AMASVisitor &visitor); void accept(AMASVisitor &visitor);
/** /**
...@@ -80,7 +90,7 @@ class Synchronization : public Action { ...@@ -80,7 +90,7 @@ class Synchronization : public Action {
* conversion of Synchronization type and a push back of the name of the * conversion of Synchronization type and a push back of the name of the
* Channel instance associated. * Channel instance associated.
*/ */
vector<string> get_info_vector(); std::vector<std::string> get_info_vector();
/* Sets */ /* Sets */
/** /**
......
#include "synchronization_type.hpp" #include "synchronization_type.hpp"
string to_string(SynchronizationType sh) { using namespace std;
string to_string(SynchronizationType sync_type) {
string sh_ = ""; string sh_ = "";
switch (sh) { switch (sync_type) {
case SynchronizationType::Send: case SynchronizationType::Send:
sh_ = "!"; sh_ = "!";
break; break;
......
#ifndef SYNCHRONIZATION_TYPE_HPP #ifndef SYNCHRONIZATION_TYPE_HPP
#define SYNCHRONIZATION_TYPE_HPP #define SYNCHRONIZATION_TYPE_HPP
#include <iostream> #include <string>
using namespace std;
/** /**
* @ingroup eamas_action
*
* SynchronizationType enum class. * SynchronizationType enum class.
* *
* Eventually, automaton does synchronization which must be a match: Send or * Eventually, automaton does synchronization which must be a match: Send or
* Receive. * Receive.
*/ */
enum class SynchronizationType { enum class SynchronizationType { Send, Receive };
Send, // 0
Receive // 1
};
// methods /**
* Returns the string representation of the synchronization type.
string to_string(SynchronizationType sh); *
* @param sync_type synchronization type.
*
* @return a string with the synchronization type.
*/
std::string to_string(SynchronizationType sync_type);
#endif #endif
#include "transition.hpp" #include "transition.hpp"
#include "update.hpp" #include "update.hpp"
using namespace std;
Transition::Transition(State *source_state, State *destination_state, Transition::Transition(State *source_state, State *destination_state,
Action *action, vector<Update *> updates) Action *action, vector<Update *> updates)
: source_state_(source_state), : source_state_(source_state),
......
...@@ -126,7 +126,7 @@ class Transition { ...@@ -126,7 +126,7 @@ class Transition {
* @return A string type corresponding to the to the word (Transition) * @return A string type corresponding to the to the word (Transition)
* concatenate with id number and info of a Action instance. * concatenate with id number and info of a Action instance.
*/ */
string get_info(); std::string get_info();
void accept(AMASVisitor &visitor); void accept(AMASVisitor &visitor);
......
...@@ -9,6 +9,8 @@ ...@@ -9,6 +9,8 @@
#include "leaf.hpp" #include "leaf.hpp"
#include "variable.hpp" #include "variable.hpp"
using namespace std;
Translator::Translator() {} Translator::Translator() {}
Translator::~Translator() {} Translator::~Translator() {}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment