diff --git a/AUTHORS.md b/AUTHORS.md index 98c962787c382c9bda7559eb02a1c1b602b897a8..70e802cae07d9247c8fd114f6934db82e7fafb91 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -2,3 +2,9 @@ - Jaime ARIAS (arias@lipn.univ-paris13.fr) - 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) diff --git a/docs/setup.hpp b/docs/setup.hpp index d728a74c2957c1aeafd7e0fdbe61bb48f8aa7dd5..e39e8a028c5a1c14ea8e589504d7e9f4290bf71d 100644 --- a/docs/setup.hpp +++ b/docs/setup.hpp @@ -18,6 +18,11 @@ * @defgroup eamas Extended Asynchronous Multi-Agents Systems */ +/** + * @defgroup eamas_action EAMAS' Actions + * @ingroup eamas + */ + /** * @defgroup adt2amas Translator ADTree into EAMAS */ diff --git a/src/amas/action.hpp b/src/amas/action.hpp index 1a5028f44f98c0862b65ca0bdc1cc4872f859b16..0026320213939fd1d2da29c88cdcd16347c7f9e7 100644 --- a/src/amas/action.hpp +++ b/src/amas/action.hpp @@ -1,12 +1,10 @@ #ifndef ACTION_HPP #define ACTION_HPP -#include <iostream> +#include <string> #include <vector> -// #include "amas_visitor.hpp" - -// class AMASVisitor; +//! \ingroup eamas_action //! Action entity, associated to a transition to represent either a //! Synchronization or a Label implementations. /*! Action is an abstract class since it has at least one pure virtual @@ -20,8 +18,6 @@ class Action { //! A pure virtual member. virtual std::string get_info() = 0; - // virtual void accept(AMASVisitor &visitor) = 0; - //! A pure virtual member. virtual std::vector<std::string> get_info_vector() = 0; }; diff --git a/src/amas/automata.hpp b/src/amas/automata.hpp index e8f9f054cef6527f2c669a6cd6215defdcf9587e..dd51aaeae06a6da4bc6a3d489924c9a322d44b55 100644 --- a/src/amas/automata.hpp +++ b/src/amas/automata.hpp @@ -1,6 +1,9 @@ #ifndef AUTOMATA_HPP #define AUTOMATA_HPP +#include <set> +#include <string> +#include <vector> #include "automaton.hpp" #include "channel.hpp" #include "parser/amas_visitor.hpp" @@ -9,6 +12,8 @@ class Automaton; class AMASVisitor; /** + * \ingroup eamas + * * 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 * agents (Automaton) and channels. The former communicate and synchronize @@ -22,7 +27,7 @@ class Automata { ids must be unique and can not exist twice same Automaton instances in Automata. */ - set<int> automaton_ids_; + std::set<int> automaton_ids_; //! A private attribute of set type to collect integers. /*! @@ -30,21 +35,21 @@ class Automata { ids must be unique and can not exist twice same Channel instances in Automata. */ - set<int> channel_ids_; + std::set<int> channel_ids_; //! A private attribute of vector type to collect Automaton pointers. /*! It is used to save Automaton pointers which are in the Automata. The 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. /*! It is used to save Channel pointers which are in the Automata. The pointers here must be correlated with ids saved in channel_ids_. */ - vector<Channel *> channels_; + std::vector<Channel *> channels_; public: //! Automata constructor. @@ -53,6 +58,7 @@ An instance of Automata is created empty and following, it is possible to add Automaton and Channel instances. */ Automata(); + //! Action destructor. ~Automata(); @@ -63,7 +69,7 @@ Automaton and Channel instances. Member part of getters. \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 //! Automata instance. @@ -72,14 +78,14 @@ Automaton and Channel instances. \return A set of type int which are Automaton ids associated with this Automata instance. */ - set<int> get_automaton_ids(); + std::set<int> get_automaton_ids(); //! A public method to get vector pointers of Channel instances. /*! Member part of getters. \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. /*! @@ -87,8 +93,12 @@ Automaton and Channel instances. \return A string which contain information about an Automata instance, 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); /* Sets */ diff --git a/src/amas/automaton.hpp b/src/amas/automaton.hpp index 9258b802e94b02b810b51812a4f1aa15082810ce..7d2c3969677499961f58416b85549c46add9eac9 100644 --- a/src/amas/automaton.hpp +++ b/src/amas/automaton.hpp @@ -2,6 +2,7 @@ #define AUTOMATON_HPP #include <set> +#include <string> #include <vector> #include "action.hpp" #include "parser/amas_visitor.hpp" @@ -13,6 +14,7 @@ class AMASVisitor; class State; class Transition; +//! \ingroup eamas //! Automaton entity, compose by states and transitions to connect them. /*! A class to model an agent which is an abstract machine with states and @@ -49,7 +51,7 @@ class Automaton { 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. */ - set<int> state_ids_; + std::set<int> state_ids_; //! A private attribute of set type to collect integers. /*! @@ -57,21 +59,21 @@ class Automaton { since ids must be unique and can not exist twice same Transition instances in Automaton. */ - set<int> transition_ids_; + std::set<int> transition_ids_; //! A private attribute of vector type to collect State 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_. */ - vector<State *> states_; + std::vector<State *> states_; //! A private attribute of vector type to collect Transition pointers. /*! It is used to save Transition pointers which are in the Automaton. The 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 //! because removing a state. @@ -105,6 +107,7 @@ class Automaton { of this Automaton instance. */ Automaton(State *initial_state); + //! Automaton destructor. /*! It deletes their pointer to initial_state_. @@ -133,7 +136,7 @@ class Automaton { \return A set of type int which are State ids associated with this 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 //! Automaton instance. @@ -142,21 +145,21 @@ class Automaton { \return A set of type int which are Transition ids associated with this Automaton instance. */ - set<int> get_transition_ids(); + std::set<int> get_transition_ids(); //! A public method to get vector pointers of State instances. /*! Member part of getters. \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. /*! Member part of getters. \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. /*! @@ -165,8 +168,12 @@ class Automaton { their State and Transition instances. Indentation applied for each 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); /* Sets */ @@ -196,7 +203,7 @@ class Automaton { same entries. */ 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. /*! diff --git a/src/amas/channel.cpp b/src/amas/channel.cpp index 9359eb6aaf2b4d98a57228cbc17ef6b08f1aa83c..611efb0dc8e0c71b253c8a3750ccdfc7618a4fda 100644 --- a/src/amas/channel.cpp +++ b/src/amas/channel.cpp @@ -1,5 +1,7 @@ #include "channel.hpp" +using namespace std; + Channel::Channel(string name) : name_(name) { ++current_id; id = current_id; diff --git a/src/amas/channel.hpp b/src/amas/channel.hpp index 89068b982221caa771a7498df31158f9bddde217..d03db8e31d7ac9407ddb2cf9ddc4ad26e3758c61 100644 --- a/src/amas/channel.hpp +++ b/src/amas/channel.hpp @@ -1,11 +1,11 @@ #ifndef CHANNEL_HPP #define CHANNEL_HPP -#include <iostream> - -using namespace std; +#include <string> /** + * @ingroup eamas_action + * * Channel entity, part of Automata used to synchronize Automaton. * 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. @@ -31,7 +31,7 @@ class Channel { /** * A private attribute of string type to save a Channel name instance. */ - string name_; + std::string name_; public: /** @@ -40,7 +40,7 @@ class Channel { * * @param name is a default argument which if not passed, is an empty string. */ - Channel(string name = ""); + Channel(std::string name = ""); /** * Channel destructor. */ @@ -59,7 +59,7 @@ class Channel { * * @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. @@ -67,7 +67,7 @@ class Channel { * @return A string type corresponding to the word (Channel) concatenate with * id number and name of a Channel instance. */ - string get_info(); + std::string get_info(); /* Sets */ @@ -76,6 +76,6 @@ class Channel { * * @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 diff --git a/src/amas/label.cpp b/src/amas/label.cpp index 5580e00764e2f00346f5a73221a3f78fdac05c33..a5c263c3afdeefdbdc944778414b5d1ce8fa8ff1 100644 --- a/src/amas/label.cpp +++ b/src/amas/label.cpp @@ -1,5 +1,7 @@ #include "label.hpp" +using namespace std; + Label::Label(string name) : name_(name) {} Label::~Label() {} diff --git a/src/amas/label.hpp b/src/amas/label.hpp index 14538965cb08bd871035e671baff49dc311d3027..4e6741f87f62ad38ab1ff4d8b9f9f6da0e5d078d 100644 --- a/src/amas/label.hpp +++ b/src/amas/label.hpp @@ -9,6 +9,8 @@ class AMASVisitor; /** + * @ingroup eamas_action + * * Label entity, an Action which does not synchronize. * * It is an implementation for Action interface and set a name for an action @@ -29,6 +31,7 @@ class Label : public Action { * @param name is a default argument which if not passed, is an empty string. */ Label(std::string name = ""); + /** * Label destructor. */ @@ -50,6 +53,11 @@ class Label : public Action { */ std::string get_info(); + /** + * A public method implementing the visitor pattern + * + * @param visitor is a visitor instance + */ void accept(AMASVisitor &visitor); /** diff --git a/src/amas/state.cpp b/src/amas/state.cpp index 1c91e344382e8097cf608c3770afb390e61fa308..375eb82ea1c95c0b1f68626aa3e9422273fcff22 100644 --- a/src/amas/state.cpp +++ b/src/amas/state.cpp @@ -1,5 +1,6 @@ #include "state.hpp" #include <string> +#include <vector> using namespace std; diff --git a/src/amas/state.hpp b/src/amas/state.hpp index 0c393475c190083adb8715f9a1538b62c725b4d0..edf235449ac8c4e00967b7f05b8bfc7a92ea880e 100644 --- a/src/amas/state.hpp +++ b/src/amas/state.hpp @@ -2,6 +2,7 @@ #define STATE_HPP #include <string> +#include <vector> #include "parser/amas_visitor.hpp" #include "state_type.hpp" #include "transition.hpp" @@ -41,7 +42,7 @@ class State { * A private attribute of vector type to collect Transition pointers. * It is used to save Transition pointers associated with a State instance. */ - vector<Transition *> transitions_; + std::vector<Transition *> transitions_; public: /** @@ -79,7 +80,7 @@ class State { * @return A vector of type Transition pointers, which are associated to a * State instance. */ - vector<Transition *> get_transitions(); + std::vector<Transition *> get_transitions(); /** * A public method to get the info of a State instance. @@ -116,6 +117,6 @@ class State { * @param transitions is a vector for the new transition pointers to be * assigned in transitions_ attribute. */ - void set_transitions(vector<Transition *> transitions); + void set_transitions(std::vector<Transition *> transitions); }; #endif diff --git a/src/amas/state_type.cpp b/src/amas/state_type.cpp index 2c35f997b4771543b81311020f6c6c437d05c9e7..84927d9274cc5103a067f6fe976d0910775bfd89 100644 --- a/src/amas/state_type.cpp +++ b/src/amas/state_type.cpp @@ -1,5 +1,7 @@ #include "state_type.hpp" +using namespace std; + string to_string(StateType st) { string _st = ""; switch (st) { diff --git a/src/amas/state_type.hpp b/src/amas/state_type.hpp index 627a972c4024dfeca29ac135bd4d78d095061c65..70a37fcbd9558a8e2926d59385b4a4a350b3beb6 100644 --- a/src/amas/state_type.hpp +++ b/src/amas/state_type.hpp @@ -1,21 +1,16 @@ #ifndef STATE_TYPE_HPP #define STATE_TYPE_HPP -#include <iostream> #include <string> -using namespace std; - /** + * @ingroup eamas + * * StateType enum class. * * by definition there are three types of States: initial, normal and accepted. */ -enum class StateType { - Normal, // 0 - Initial, // 1 - Accepted // 2 -}; +enum class StateType { Normal, Initial, Accepted }; // methods @@ -26,6 +21,6 @@ enum class StateType { * @return A string type corresponding to the mapping function implemented for * the st argument. */ -string to_string(StateType st); +std::string to_string(StateType st); #endif diff --git a/src/amas/synchronization.cpp b/src/amas/synchronization.cpp index 9bd61590959daa85daf68a066a41a5a65b048640..7622a11572baa2175b46091cd8ca4c9ff34a24a0 100644 --- a/src/amas/synchronization.cpp +++ b/src/amas/synchronization.cpp @@ -1,5 +1,6 @@ #include "synchronization.hpp" -#include <bits/stdc++.h> + +using namespace std; Synchronization::Synchronization(SynchronizationType synchronization_type, Channel *channel) diff --git a/src/amas/synchronization.hpp b/src/amas/synchronization.hpp index a0e17f36ac5107aa15783ab760fc62280cfbdcc5..8079608e30ef9b65f02d315533044775b1e0abea 100644 --- a/src/amas/synchronization.hpp +++ b/src/amas/synchronization.hpp @@ -1,6 +1,8 @@ #ifndef SYNCHRONIZATION_HPP #define SYNCHRONIZATION_HPP +#include <string> +#include <vector> #include "action.hpp" #include "channel.hpp" #include "parser/amas_visitor.hpp" @@ -9,6 +11,8 @@ class AMASVisitor; /** + * @ingroup eamas_action + * * Synchronization entity, an action used to synchronize automaton. * * It is an implementation for Action interface and set a type to synchronize @@ -41,6 +45,7 @@ class Synchronization : public Action { Synchronization( SynchronizationType synchronization_type = SynchronizationType::Send, Channel *channel = nullptr); + /** * Channel destructor. */ @@ -69,8 +74,13 @@ class Synchronization : public Action { * Synchronization type concatenate the name of the Channel instance * 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); /** @@ -80,7 +90,7 @@ class Synchronization : public Action { * conversion of Synchronization type and a push back of the name of the * Channel instance associated. */ - vector<string> get_info_vector(); + std::vector<std::string> get_info_vector(); /* Sets */ /** diff --git a/src/amas/synchronization_type.cpp b/src/amas/synchronization_type.cpp index ed692785db2bf8eb30a337e4b5dd56350c5e0437..5d384696591d565f3087f5d6eef9d392c3945e2f 100644 --- a/src/amas/synchronization_type.cpp +++ b/src/amas/synchronization_type.cpp @@ -1,8 +1,10 @@ #include "synchronization_type.hpp" -string to_string(SynchronizationType sh) { +using namespace std; + +string to_string(SynchronizationType sync_type) { string sh_ = ""; - switch (sh) { + switch (sync_type) { case SynchronizationType::Send: sh_ = "!"; break; diff --git a/src/amas/synchronization_type.hpp b/src/amas/synchronization_type.hpp index 80e31d35f4e13858e32602211789b63d8b63b6d6..fcf0cda24cd22037f45a8db587e47bd1d70fee36 100644 --- a/src/amas/synchronization_type.hpp +++ b/src/amas/synchronization_type.hpp @@ -1,23 +1,25 @@ #ifndef SYNCHRONIZATION_TYPE_HPP #define SYNCHRONIZATION_TYPE_HPP -#include <iostream> - -using namespace std; +#include <string> /** + * @ingroup eamas_action + * * SynchronizationType enum class. * * Eventually, automaton does synchronization which must be a match: Send or * Receive. */ -enum class SynchronizationType { - Send, // 0 - Receive // 1 -}; +enum class SynchronizationType { Send, Receive }; -// methods - -string to_string(SynchronizationType sh); +/** + * Returns the string representation of the synchronization type. + * + * @param sync_type synchronization type. + * + * @return a string with the synchronization type. + */ +std::string to_string(SynchronizationType sync_type); #endif diff --git a/src/amas/transition.cpp b/src/amas/transition.cpp index f972641cead98c928ed053d09cfdbd4ca0ecb8f9..aed9b9a0339c759e36218daa903a5cbdc093052b 100644 --- a/src/amas/transition.cpp +++ b/src/amas/transition.cpp @@ -1,6 +1,8 @@ #include "transition.hpp" #include "update.hpp" +using namespace std; + Transition::Transition(State *source_state, State *destination_state, Action *action, vector<Update *> updates) : source_state_(source_state), diff --git a/src/amas/transition.hpp b/src/amas/transition.hpp index 2d04f0b09865d92162b0ffe6960e08fa58f86d39..4b08cd006fe925fa55653e512880c0a0845d4763 100644 --- a/src/amas/transition.hpp +++ b/src/amas/transition.hpp @@ -126,7 +126,7 @@ class Transition { * @return A string type corresponding to the to the word (Transition) * concatenate with id number and info of a Action instance. */ - string get_info(); + std::string get_info(); void accept(AMASVisitor &visitor); diff --git a/src/translator.cpp b/src/translator.cpp index cdef6af4f7f38335053f24ea6cc29e63b40b15d0..346d4474855af8345d79dc07282b05fb9c4f5431 100644 --- a/src/translator.cpp +++ b/src/translator.cpp @@ -9,6 +9,8 @@ #include "leaf.hpp" #include "variable.hpp" +using namespace std; + Translator::Translator() {} Translator::~Translator() {} diff --git a/tests/amas/state.cpp b/tests/amas/state.cpp index dbb569c39b23db838ac2fa294f935d83bd389f40..fcf2f490b902b9f264a33f59cef2879a17ea436b 100644 --- a/tests/amas/state.cpp +++ b/tests/amas/state.cpp @@ -1,5 +1,8 @@ #include "state.hpp" #include <catch.hpp> +#include <vector> + +using namespace std; /* TODO: * 1) Change state type by a property of the state