Commit 2edd78f7 authored by Clément Vuchener's avatar Clément Vuchener

Documentation dans la trace

parent 386a295b
......@@ -2,12 +2,7 @@
#define CONTAINER_HPP
/*!
*
* \file Container.hpp
* \author Clément Vuchener
* \brief Contains the definition of the class Container
* \date 2009 January 30th
*
*/
#include <list>
......@@ -30,13 +25,9 @@ class Container;
#include "VariableType.hpp"
#include "Variable.hpp"
#define STATE_STACK_SIZE 16
/*!
*
* \class Container
* \brief contains others containers or entities
*
* \brief Contains others containers or entities
*/
class Container {
friend class State;
......@@ -76,173 +67,180 @@ private:
void add_current_state(Date end);
public:
/*!
* \fn Container(Name name, Date creation_time, ContainerType *type, Container *parent)
* \brief Constructor of Container
* \arg name Name of the container
* \arg creation_time Date when the container was created
* \arg type Type of the container
* \arg parent Parent container (NULL if the container is root)
*/
Container(Name name, Date creation_time, ContainerType *type, Container *parent);
/*!
* \fn ~Container()
* \brief Destructor of Container
*/
~Container();
/*!
*
* \fn add_child(Container *)
*
* \brief Add a child to the container
* \arg child new child container
*/
void add_child(Container *);
void add_child(Container *child);
/*!
*
* \fn set_state(Date time, StateType *type, EntityValue *value)
*
* \brief Set the current state of the container
* \arg time Date of the event
* \arg type Type of the state
* \arg value Value of the state
*/
void set_state(Date time, StateType *type, EntityValue *value);
/*!
*
* \fn push_state(Date time, StateType *type, EntityValue *value)
*
* \brief Set the current state of the container and save the previous state
* \arg time Date of the event
* \arg type Type of the state
* \arg value Value of the state
*/
void push_state(Date time, StateType *type, EntityValue *value);
/*!
*
* \fn pop_state(Date time)
*
* \brief Restore a previous state
* \arg time Date of the event
*/
void pop_state(Date time);
/*!
*
* \fn new_event(Date time, EventType *type, EntityValue *value)
*
* \brief Add a new event
* \arg time Date of the event
* \arg type Type of the event
* \arg value Value of the event
*/
void new_event(Date time, EventType *type, EntityValue *value);
/*!
*
* \fn start_link(Date time, LinkType *type, Container *source, Container *destination, EntityValue *value, String key)
*
* \fn start_link(Date time, LinkType *type, Container *source, EntityValue *value, String key)
* \brief Start a new link identified by key
* \arg time Date of the start of the link
* \arg type Type of the link
* \arg source Container from where the link is sent
* \arg value Value of the link
* \arg key String that identifies the link to match its end
*/
void start_link(Date time, LinkType *type, Container *source, EntityValue *value, String key);
/*!
*
* \fn end_link(Date time, String key)
*
* \fn end_link(Date time, Container *destination, String key)
* \brief End a link identified by key
* \arg time Date of the end of the link
* \arg destination Container to where the link is sent
* \arg key String that identifies the link to match its beginning
*/
void end_link(Date time, Container *destination, String key);
/*!
*
* \fn set_variable(Date time, VariableType *type, Double value)
*
* \brief Set a new value of a variable
* \arg time Date of the event
* \arg type Type of the variable
* \arg value New value of the variable
*/
void set_variable(Date time, VariableType *type, Double value);
/*!
*
* \fn add_variable(Date time, VariableType *type, Double value)
*
* \brief Add a value to the current value of a variable
* \arg time Date of the event
* \arg type Type of the variable
* \arg value Value to add
*/
void add_variable(Date time, VariableType *type, Double value);
/*!
*
* \fn set_variable(Date time, VariableType *type, Double value)
*
* \fn sub_variable(Date time, VariableType *type, Double value)
* \brief Substract a value to the current value of a variable
* \arg time Date of the event
* \arg type Type of the variable
* \arg value Value to substract
*/
void sub_variable(Date time, VariableType *type, Double value);
/*!
*
* \fn get_name() const
* \brief Returns the name and the alias of the container
*
* \brief Get the name and the alias of the container
*/
Name get_name() const;
/*!
*
* \fn get_parent() const
* \brief Returns the parent container
*
* \brief Get the parent container
*/
const Container *get_parent() const;
/*!
*
* \fn get_type() const
* \brief Returns the type of the container
*
* \brief Get the type of the container
*/
const ContainerType *get_type() const;
/*!
*
* \fn get_children() const
* \brief Returns the list of the child containers
*
* \brief Get the list of the child containers
*/
const list<Container *> *get_children() const;
/*!
*
* \fn get_creation_time() const
* \brief Returns the time when the container was created
*
* \brief Get the time when the container was created
*/
Date get_creation_time() const;
/*!
*
* \fn get_destruction_time() const
* \brief Returns the time when the container was destroyed
*
* \brief Get the time when the container was destroyed
*/
Date get_destruction_time() const;
/*!
*
* \fn get_states() const
* \brief Returns the state list
*
* \brief Get the state list
*/
const list<State *> *get_states() const;
/*!
*
* \fn get_events() const
* \brief Returns the event list
*
* \brief Get the event list
*/
const list<Event *> *get_events() const;
/*!
*
* \fn get_links() const
* \brief Returns the link list
*
* \brief Get the link list
*/
const list<Link *> *get_links() const;
/*!
*
* \fn get_variables() const
* \brief Returns the variables
*
* \brief Get the variables
*/
const map<VariableType *, Variable *> *get_variables() const;
/*!
*
* \fn get_variable_number() const
* \brief Returns the number of variables
*
* \brief Get the number of variables
*/
int get_variable_number() const;
/*!
*
* \fn destroy(const Date &time)
* \brief Sets the destruction time of the container
* \param time destruction time
*
* \arg time Destruction tim
*/
void destroy(const Date &time);
};
......
#ifndef CONTAINERTYPE_HPP
#define CONTAINERTYPE_HPP
/*!
* \file ContainerType.hpp
*/
#include <list>
using std::list;
#include "values/Name.hpp"
/*!
*
* \file ContainerType.hpp
* \author Clément Vuchener
* \brief Contains the definition of the class Container
* \date 2009 January 30th
*
*/
/*!
*
* \class ContainerType
* \brief describe the type of a container
*
* \brief Describe the type of a container
*/
class ContainerType {
private:
......@@ -28,27 +21,38 @@ private:
list<ContainerType *> _children;
public:
/*!
* \fn ContainerType(Name &name, ContainerType *parent)
* \brief Constructor of ContainerType
* \arg name Name of the container type
* \arg parent Type of the parent container
*/
ContainerType(Name &name, ContainerType *parent);
/*!
* \fn ~ContainerType()
* \brief Destructor
*/
~ContainerType();
void add_child(ContainerType *);
/*!
* \fn add_child(ContainerType *child)
* \brief Add a type of child container
* \arg child Type of child container
*/
void add_child(ContainerType *child);
Name get_name();
/*!
*
* \fn get_parent() const
* \brief Returns the parent container type
*
* \brief Get the parent container type
*/
const ContainerType *get_parent() const;
/*!
*
* \fn get_children() const
* \brief Returns the list of the child container types
*
* \brief Get the list of the child container types
*/
const list<ContainerType *> *get_children() const;
};
......
......@@ -12,10 +12,10 @@
#include "../interface/render_area.hpp"
#include "../message/message_ns.hpp"
//using namespace message_ns;
/*!
* \brief
* \class DrawTrace
* \brief Browse the trace and call back T drawing methods
*/
template<class T>
class DrawTrace
......@@ -192,6 +192,14 @@ public:
return size;
}
/*!
* \brief Draw a container
* \param draw_object Object that contains drawing methods to call
* \param position Starting line of the container
* \param size Height of the container in number of line
* \param depth Depth of container in the tree
* \param text Name of the container
*/
inline void draw_container(T* draw_object, int position, int size, int depth, const std::string &text) {
Element_pos x = depth*(_container_width+_container_h_space) + _container_h_space/2;
Element_pos y = position*(_container_height+_container_v_space) + _container_v_space/2;
......@@ -319,22 +327,53 @@ public:
}
/*!
* \brief Draw a state
* \param draw_object Object that contains the drawing methods
* \param starttime Time when the state begins
* \param endtime Time when the state ends
* \param position Line where the state is drawn
* \param r Red value of the state color
* \param g Green value of the state color
* \param b Blue value of the state color
*/
inline void draw_state(T *draw_object, double starttime, double endtime, int position, double r, double g, double b) {
Element_pos y = position*(_container_height+_container_v_space) + _container_v_space/2;
draw_object->draw_state(starttime, endtime, y, _state_height, r, g, b);
}
/*!
* \brief Draw an event
* \param draw_object Object that contains the drawing methods
* \param time Time of the event
* \param position Line where the event is drawn
*/
inline void draw_event(T *draw_object, double time, int position) {
Element_pos y = position*(_container_height+_container_v_space) + _container_v_space/2;
draw_object->draw_event(time, y, _state_height);
}
/*!
* \brief Draw a point of a variable curve
* \param draw_object Object that contains the drawing methods
* \param time Time of the point
* \param value Value of of the variable (between 0.0 and 1.0)
* \param position Line where the variable is drawn
*/
inline void draw_variable_value(T *draw_object, double time, double value, int position) {
Element_pos y = (position+1)*(_container_height+_container_v_space) - _container_v_space/2 -
value*_container_height;
draw_object->draw_counter(time, y);
}
/*!
* \brief Draw a link
* \param draw_object Object that contains the drawing methods
* \param starttime Time of the start of the link
* \param endtime Time of the end of the link
* \param start Line of the start of the link
* \param end Line of the end of the link
*/
inline void draw_link(T *draw_object, double starttime, double endtime, int start, int end) {
Element_pos y1 = ((double)start+0.5)*(_container_height+_container_v_space);
Element_pos y2 = ((double)end+0.5)*(_container_height+_container_v_space);
......
......@@ -2,21 +2,14 @@
#define ENTITY_HPP
/*!
*
* \file Entity.hpp
* \author Clément Vuchener
* \brief Contains the definition of the class Container
* \date 2009 January 30th
*
*/
class Container;
/*!
*
* \class Container
* \brief abstract class that describe trace entities (events, states, links, variables)
*
* \class Entity
* \brief Abstract class that describe trace entities (events, states, links, variables)
*/
class Entity {
private:
......@@ -26,7 +19,10 @@ protected:
Entity(Container *container);
public:
/*!
* \fn get_container() const
* \brief Get the container of the entity
*/
const Container *get_container() const;
};
......
#include "EntityList.hpp"
EntityList::EntityList() {
_beginning = 0;
_end = 0;
_current = 0;
}
EntityList::EntityList(const EntityList& list) {
EntityListElement *el, *src;
if (list.is_empty()) { // Empty list
_beginning = 0;
_end = 0;
_current = 0;
}
else if (list._beginning == list._end) { // One element list
el = new EntityListElement;
el->next = el->previous = 0;
el->ent = list._beginning->ent;
_beginning = _end = _current = el;
}
else { // Multiple element list
// First element
el = new EntityListElement;
el->previous = 0;
el->ent = list._beginning->ent;
_beginning = el;
if (list._current == list._beginning)
_current = el;
// nth element;
for (src = list._beginning; src != 0; src = src->next) {
el->next = new EntityListElement;
el->next->previous = el;
el->next->ent = src->ent;
el = el->next;
if (list._current == src)
_current = el;
}
// last element
el->next = 0;
_end = el;
}
}
EntityList::~EntityList(){
// For each entity of the list, we delete it
while(!is_empty()) {
this->remove_current();
}
}
bool EntityList::is_empty() const {
return _current == 0;
}
void EntityList::go_beginning() {
_current = _beginning;
}
void EntityList::go_end() {
_current = _end;
}
void EntityList::insert_after(const Entity *ent) {
EntityListElement *el = new EntityListElement;
el->ent = ent;
if (_current) {
el->next = _current->next;
el->previous = _current;
if (_current->next)
_current->next->previous = el;
_current->next = el;
if (_current == _end)
_end = el;
}
else { // There is no element in the list
el->next = 0;
el->previous = 0;
_beginning = _end = _current = el;
}
}
void EntityList::remove_current() {
EntityListElement *el = _current;
if (el) {
if (el->previous)
el->previous->next = el->next;
if (el->next)
el->next->previous = el->previous;
if (el == _beginning)
_beginning = el->next;
if (el == _end)
_end = el->previous;
if (el->next)
_current = el->next;
else
_current = el->previous;
delete el;
}
}
void EntityList::next() {
if (_current && _current->next)
_current = _current->next;
}
bool EntityList::has_next() const {
return (_current && _current->next != NULL);
}
void EntityList::previous() {
if (_current && _current->previous)
_current = _current->previous;
}
bool EntityList::has_previous() const {
return (_current && _current->previous != 0);
}
const Entity *EntityList::get_current_entity() const {
if (_current)
return _current->ent;
else
return 0;
}
#ifndef ENTITYLIST_HPP
#define ENTITYLIST_HPP
class EntityList;
#include "Entity.hpp"
struct EntityListElement {
EntityListElement *next;
EntityListElement *previous;
const Entity *ent;
};
class EntityList {
private:
EntityListElement *_beginning;
EntityListElement *_end;
EntityListElement *_current;
public:
/*!
*
*\fn EntityList()
*\brief Destructor
*
*/
~EntityList();
/*!
*
*\fn EntityList()
*\brief Default constructor, create an empty list
*
*/
EntityList();
/*!
*
*\fn EntityList()
*\brief Copy constructor
*
*/
EntityList(const EntityList &);
/*!
*
* \fn is_empty() const
* \return true if the list is empty
*
*/
bool is_empty() const;
/*!
*
*\fn go_beginning()
*\brief Set the current element to be the first of the list
*
*/
void go_beginning();
/*!
*
*\fn go_end()
*\brief Set the current element to be the last of the list
*
*/
void go_end();
/*!
*
*\fn insert_after(const Entity *cont)
*\brief add an entity at the current position in the list
*
*/
void insert_after(const Entity *cont);
/*!
*
*\fn remove_current()
*\brief Remove the current entity
*
*/
void remove_current();
/*!
*
*\fn next()
*\brief Return the next element
*
*/
void next();
/*!
*
*\fn has_next() const
*\brief Return if there is a following element
*
*/
bool has_next() const;
/*!
*
*\fn previous()
*\brief Return the previous element
*
*/
void previous();
/*!
*