Maj terminée. Pour consulter la release notes associée voici le lien :
https://about.gitlab.com/releases/2021/07/07/critical-security-release-gitlab-14-0-4-released/

Commit f32f3cd8 authored by Clément Vuchener's avatar Clément Vuchener
Browse files

Modification du stockage d'états et ajout du stackage d'evenement

parent 47249c40
......@@ -32,6 +32,8 @@ HEADERS += interface.hpp \
../../trace/src/EntityValue.hpp \
../../trace/src/State.hpp \
../../trace/src/StateType.hpp \
../../trace/src/Event.hpp \
../../trace/src/EventType.hpp \
../../trace/src/Trace.hpp \
../../trace/src/values/Color.hpp \
../../trace/src/values/Date.hpp \
......@@ -66,6 +68,8 @@ render_area.cpp \
../../trace/src/EntityValue.cpp \
../../trace/src/State.cpp \
../../trace/src/StateType.cpp \
../../trace/src/Event.cpp \
../../trace/src/EventType.cpp \
../../trace/src/Trace.cpp \
../../trace/src/values/Color.cpp \
../../trace/src/values/Date.cpp \
......
#include "Container.hpp"
#include <iostream>
Container::Container(Name &name, Date &creation_time, ContainerType *type, Container *parent):
Container::Container(Name name, Date creation_time, ContainerType *type, Container *parent):
_name(name), _creation_time(creation_time), _type(type), _parent(parent) {
_state_stack.index = -1;
_states = new EntityList;
}
template <class T>
static void clear_list(list<T *> &l) {
for (typename list<T *>::iterator it = l.begin();
it != l.end();
it++) {
delete *it;
}
}
Container::~Container() {
// Delete children
while (!_children.empty()){
delete _children.front();
_children.pop_front();
}
clear_list<Container>(_children);
// Delete states
_states->go_beginning();
while (!_states->is_empty()) {
delete _states->get_current_entity();
_states->remove_current();
}
delete _states;
clear_list<State>(_states);
// Delete events
clear_list<Event>(_events);
}
void Container::add_child(Container *child) {
......@@ -29,8 +33,7 @@ void Container::add_child(Container *child) {
}
void Container::add_current_state(Date end) {
_states->go_end();
_states->insert_after(new State(
_states.push_back(new State(
_state_stack.states[_state_stack.index].start,
end,
_state_stack.states[_state_stack.index].type,
......@@ -64,6 +67,10 @@ void Container::pop_state(Date time) {
_state_stack.states[_state_stack.index].start = time;
}
}
void Container::new_event(Date time, EventType *type, EntityValue *value) {
_events.push_back(new Event(time, type, this, value));
}
Name Container::get_name() const {
return _name;
......@@ -89,8 +96,8 @@ Date Container::get_destruction_time() const {
return _destruction_time;
}
EntityList *Container::get_states() const {
return _states;
const list<State *> *Container::get_states() const {
return &_states;
}
void Container::destroy(const Date &time) {
......
......@@ -21,9 +21,7 @@ using std::list;
class Container;
#include "State.hpp"
#include "StateType.hpp"
#include "EntityValue.hpp"
#include "EntityList.hpp"
#include "Event.hpp"
#define STATE_STACK_SIZE 16
......@@ -41,7 +39,10 @@ private:
ContainerType *_type;
Container *_parent;
list<Container *> _children;
EntityList *_states;
list<State *> _states;
list<Event *> _events;
//list<Link *> _links;
struct state_stack_t {
struct current_state_t {
Date start;
......@@ -54,7 +55,7 @@ private:
void add_current_state(Date end);
public:
Container(Name &name, Date &creation_time, ContainerType *type, Container *parent);
Container(Name name, Date creation_time, ContainerType *type, Container *parent);
~Container();
/*!
......@@ -85,6 +86,13 @@ public:
*/
void pop_state(Date time);
/*!
*
* \fn new_event(Date time, EventType *type, EntityValue *value)
*
*/
void new_event(Date time, EventType *type, EntityValue *value);
/*!
*
* \fn get_name() const
......@@ -139,7 +147,7 @@ public:
* \brief Returns the list of the states between min and max
*
*/
EntityList *get_states() const;
const list<State *> *get_states() const;
/*!
*
......
......@@ -21,38 +21,38 @@ class DrawTrace
protected:
// Interface_graphic* _window;
std::stack<EntityList *> _stack_states;
std::stack<const list<State *> *> _stack_states;
/*!
* \brief The default height for containers.
*/
static const float _DRAWING_CONTAINER_HEIGHT_DEFAULT = 1.2f;
* \brief The default height for containers.
*/
static const float _DRAWING_CONTAINER_HEIGHT_DEFAULT = 1.2f;
/*!
* \brief The default width for containers.
*/
static const float _DRAWING_CONTAINER_WIDTH_DEFAULT = 2.5f;
/*!
* \brief The default width for containers.
*/
static const float _DRAWING_CONTAINER_WIDTH_DEFAULT = 2.5f;
/*!
* \brief The default horizontal space between containers.
*/
static const float _DRAWING_CONTAINER_H_SPACE_DEFAULT = 0.1f;
/*!
* \brief The default horizontal space between containers.
*/
static const float _DRAWING_CONTAINER_H_SPACE_DEFAULT = 0.1f;
/*!
* \brief The default vertical space between containers.
*/
static const float _DRAWING_CONTAINER_V_SPACE_DEFAULT = 0.2f;
/*!
* \brief The default vertical space between containers.
*/
static const float _DRAWING_CONTAINER_V_SPACE_DEFAULT = 0.2f;
/*!
* \brief The default height for states.
*/
static const float _DRAWING_STATE_HEIGHT_DEFAULT = 1.2f;
* \brief The default height for states.
*/
static const float _DRAWING_STATE_HEIGHT_DEFAULT = 1.2f;
/*!
* \brief The default vertical space between states.
*/
static const float _DRAWING_STATE_V_SPACE_DEFAULT = 0.2f;
/*!
* \brief The default vertical space between states.
*/
static const float _DRAWING_STATE_V_SPACE_DEFAULT = 0.2f;
/*!
......@@ -82,7 +82,7 @@ public:
/*!
* \brief The default constructor
*/
DrawTrace(){
DrawTrace() {
// _window = NULL;
_container_width = _DRAWING_CONTAINER_WIDTH_DEFAULT;
......@@ -99,7 +99,8 @@ public:
/*!
* \brief The destructor
*/
virtual ~DrawTrace(){
virtual ~DrawTrace() {
}
......@@ -118,14 +119,14 @@ public:
/*!
* \brief The trace building function.
* \param draw_object the kind of object which will be drawn (OpenGL, SVG...).
* \param _trace the trace data.
* \param trace the trace data.
*/
void build(T* draw_object, Trace* _trace){
void build(T* draw_object, Trace* trace) {
draw_object->start_draw();
draw_object->start_draw_containers();
browse_container_tree(draw_object, _trace);
browse_container_tree(draw_object, trace);
draw_object->end_draw_containers();
draw_object->start_draw_states();
......@@ -153,7 +154,7 @@ public:
*
**********************************/
inline void browse_container_tree(T* draw_object, Trace* _trace){
inline void browse_container_tree(T* draw_object, Trace* trace){
/*** Drawing containers ***/
......@@ -170,7 +171,7 @@ public:
Element_pos y_buf;/* buffer for the y position */
Element_pos height_buf;/* buffer for the container height */
const Container* container;
const std::list<Container *> *trace_container = _trace->get_root_containers();
const std::list<Container *> *trace_container = trace->get_root_containers();
std::list<Container *>::iterator it;
......@@ -321,42 +322,27 @@ public:
inline void browse_state_tree(T* draw_object){
EntityList *buf_list;
const list<State *> *buf_list;
State* buf_entity;
Element_count i;/* for the level (y axis) of the states */
i=0;
while (!_stack_states.empty()){
buf_list = _stack_states.top();
for (buf_list->go_beginning() ; buf_list->has_next() ; buf_list->next() ) {
for(list<State *>::const_iterator it = buf_list->begin();
it != buf_list->end();
it++) {
buf_entity = (State*)buf_list->get_current_entity();
buf_entity = *it;
Element_pos base = ((Element_pos)i)*_container_height+((Element_pos)i)*_container_v_space+_container_v_space;
/* Call the object state drawing function */
draw_object->draw_state(buf_entity->get_start_time().get_value(), buf_entity->get_end_time().get_value(), base, _state_height, 0.7, 0.7, 0.75);
}/* end for */
i++;
/*To draw the last element of the list*/
if(!buf_list->is_empty()){
buf_entity = (State*)buf_list->get_current_entity();
Element_pos base = ((Element_pos)i)*_container_height+((Element_pos)i)*_container_v_space+_container_v_space;
/* Call the object state drawing function */
draw_object->draw_state(buf_entity->get_start_time().get_value(), buf_entity->get_end_time().get_value(), base, _state_height, 0.7, 0.7, 0.75);
}/* end if */
/* pop the top of the stack */
_stack_states.pop();
......
......@@ -25,9 +25,7 @@ EntityType::~EntityType(){
// Destruction of the list _values
// As long as everithing has not been cleaned
while (!_values.empty()){
// Deleting the pointed area
delete _values.front();
// Deleting the element of the list
_values.pop_front();
}
}
#include "Event.hpp"
Event::Event(Date time, EventType *type, Container *container, EntityValue *value):
Entity(container), _time(time), _type(type), _value(value) {
}
Date Event::get_time() const {
return _time;
}
const EventType *Event::get_type() const {
return _type;
}
const EntityValue *Event::get_value() const {
return _value;
}
#ifndef EVENT_HPP
#define EVENT_HPP
class Event;
#include "EventType.hpp"
#include "EntityValue.hpp"
#include "values/Date.hpp"
#include "Entity.hpp"
class Event: public Entity {
private:
Date _time;
EventType *_type;
EntityValue *_value;
public:
Event(Date time, EventType *type, Container *container, EntityValue *value);
Date get_time() const;
const EventType *get_type() const;
const EntityValue *get_value() const;
};
#endif
#include "EventType.hpp"
EventType::EventType(Name name, ContainerType *container_type):
EntityType(name, container_type) {
};
#ifndef EVENTTYPE_HPP
#define EVENTTYPE_HPP
/*!
*
* \author Coulomb, Vuchener
* \brief Describes the type of the states
*
*/
class EventType;
#include "EntityType.hpp"
#include "values/Name.hpp"
#include "ContainerType.hpp"
/*!
*
*\class EventType
*\brief The class that describes the events
*
*/
class EventType : public EntityType {
private:
public :
EventType(Name name, ContainerType *container_type);
};
#endif
LD = g++
OBJ = Container.o ContainerType.o Entity.o EntityType.o EntityValue.o State.o StateType.o Trace.o #-> A decommenter quand fait
OBJ = Container.o ContainerType.o Entity.o EntityType.o EntityValue.o State.o StateType.o Event.o EventType.o Trace.o
OPT = -g -Wall -W
LIBS =
......
#include "State.hpp"
State::State(Date &start, Date &end, StateType *type, Container *container, EntityValue *value):
State::State(Date start, Date end, StateType *type, Container *container, EntityValue *value):
Entity(container), _start(start), _end(end), _type(type), _value(value) {
}
const Date &State::get_start_time() const {
Date State::get_start_time() const {
return _start;
}
const Date &State::get_end_time() const {
Date State::get_end_time() const {
return _end;
}
......
......@@ -10,12 +10,14 @@
*
*/
#include "Entity.hpp"
class State;
#include "values/Date.hpp"
#include "StateType.hpp"
#include "EntityValue.hpp"
#include "Entity.hpp"
/*!
*
* \class State
......@@ -34,7 +36,7 @@ public:
* \brief Constructor
*
*/
State(Date &start, Date &end, StateType *type, Container *container, EntityValue *value);
State(Date start, Date end, StateType *type, Container *container, EntityValue *value);
/*!
*
......@@ -42,7 +44,7 @@ public:
* \brief Returns the start time of the state
*
*/
const Date &get_start_time() const;
Date get_start_time() const;
/*!
*
......@@ -50,7 +52,7 @@ public:
* \brief Returns the end time of the state
*
*/
const Date &get_end_time() const;
Date get_end_time() const;
/*!
*
......
#include "StateType.hpp"
StateType::StateType(const Name &name, ContainerType *container_type):
StateType::StateType(Name name, ContainerType *container_type):
EntityType(name, container_type) {
};
......
......@@ -8,6 +8,8 @@
*
*/
class StateType;
#include "EntityType.hpp"
#include "values/Name.hpp"
......@@ -23,7 +25,7 @@ class StateType : public EntityType {
private:
public :
StateType(const Name &name, ContainerType *container_type);
StateType(Name name, ContainerType *container_type);
};
#endif
......@@ -41,7 +41,8 @@ void Trace::destroy_container(Date &time, Container *cont, ContainerType *type,
}
void Trace::define_event_type(Name &name, ContainerType *container_type, const vector<Value *> &opt) {
if (container_type)
_event_types.push_back(new EventType(name, container_type));
}
void Trace::define_state_type(Name &name, ContainerType *container_type, const vector<Value *> &opt) {
......@@ -78,7 +79,8 @@ void Trace::pop_state(Date &time, StateType *type, Container *container, const v
}
void Trace::new_event(Date &time, EventType *type, Container *container, EntityValue *value, const vector<Value *> &opt) {
if (container)
container->new_event(time, type, value);
}
void Trace::set_variable(Date &time, VariableType *type, Container *container, Double value, const vector<Value *> &opt) {
......@@ -151,6 +153,14 @@ Container *Trace::search_container(String name) const {
}
EventType *Trace::search_event_type(String name) const {
for (list<EventType *>::const_iterator it = _event_types.begin();
it != _event_types.end();
it++) {
if ((*it)->get_name() == name)
return *it;
}
// std::cout << "Unknown event: " << name.to_string() << std::endl;
return 0;
}
......@@ -181,6 +191,12 @@ EntityType *Trace::search_entity_type(String name) const {
if ((*it)->get_name() == name)
return *it;
}
for (list<EventType *>::const_iterator it = _event_types.begin();
it != _event_types.end();
it++) {
if ((*it)->get_name() == name)
return *it;
}
// std::cout << "Unknown entity type: " << name.to_string() << std::endl;
return 0;
......
......@@ -28,10 +28,11 @@ using std::vector;
#include "ContainerType.hpp"
#include "Container.hpp"
#include "StateType.hpp"
#include "EventType.hpp"
#include "EntityValue.hpp"
#include "State.hpp"
#include "Event.hpp"
class EventType;
class VariableType;
class LinkType;
......@@ -47,6 +48,7 @@ private:
list <ContainerType *> _root_container_types;
list <Container *> _root_containers;
list <StateType *> _state_types;
list <EventType *> _event_types;
public :
......
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