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

Déplacement des valeurs et implémentation de State et autres corrections

parent 2a3c9a10
......@@ -4,6 +4,14 @@ Container::Container(Name &name, Date &creation_time, ContainerType *type, Conta
_name(name), _creation_time(creation_time), _type(type), _parent(parent) {
_parent->_children.push_back(this);
}
Container::~Container() {
_states.go_beginning();
while (!_states.is_empty()) {
delete _states.get_current_entity();
_states.remove_current();
}
}
const Name &Container::get_name() const {
return _name;
......
......@@ -13,13 +13,14 @@
#include <list>
using std::list;
#include "../../values/name.hpp"
#include "../../values/date.hpp"
#include "values/Name.hpp"
#include "values/Date.hpp"
#include "ContainerType.hpp"
class Container;
#include "State.hpp"
#include "EntityList.hpp"
......@@ -30,15 +31,18 @@ class Container;
*
*/
class Container {
friend class State;
private:
Name _name;
Date _creation_time, _destruction_time;
ContainerType *_type;
Container *_parent;
list<Container *> _children;
EntityList _states;
public:
Container(Name &name, Date &creation_time, ContainerType *type, Container *parent);
~Container();
/*!
*
......
......@@ -4,7 +4,7 @@
#include <list>
using std::list;
#include "../../values/name.hpp"
#include "values/Name.hpp"
/*!
*
......
......@@ -9,8 +9,10 @@
* \date 2009 January 30th
*
*/
//class Entity;
#include "Container.hpp"
//#include "Container.hpp"
/*!
*
......@@ -21,7 +23,7 @@
class Entity {
public:
Container &get_container() const;
// virtual const Container *get_container() const = 0;
};
#endif
......@@ -5,6 +5,10 @@ EntityList::EntityList() {
_end = 0;
_current = 0;
}
bool EntityList::is_empty() const {
return _current == 0;
}
void EntityList::go_beginning() {
_current = _beginning;
......
#ifndef ENTITYLIST_HPP
#define ENTITYLIST_HPP
class EntityList;
#include "Entity.hpp"
struct EntityListElement {
......@@ -25,6 +23,14 @@ public:
*
*/
EntityList();
/*!
*
* \fn is_empty
* \return true if the list is empty
*
*/
bool is_empty() const;
/*!
*
......
#include "State.hpp"
State::State(Date &start, Date &end, StateType *type, Container *container, EntityValue *value):
_start(start), _end(end), _type(type), _container(container), _value(value) {
_container->_states.go_end();
_container->_states.insert_after(this);
}
const Date &State::get_start_time() const {
return _start;
}
const Date &State::get_end_time() const {
return _end;
}
const double State::get_duration() const {
return _end - _start;
}
const StateType *State::get_type() const {
return _type;
}
const EntityValue *State::get_value() const {
return _value;
}
const Container *State::get_container() const {
return _container;
}
......@@ -10,7 +10,11 @@
*
*/
#include "entity.hpp"
#include "Entity.hpp"
#include "values/Date.hpp"
#include "StateType.hpp"
#include "EntityValue.hpp"
/*!
*
......@@ -18,14 +22,20 @@
* \brief An container state
*
*/
class State: public Entity {
class State: public Entity {
private:
Date _start, _end;
StateType *_type;
Container *_container;
EntityValue *_value;
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);
/*!
*
......@@ -57,7 +67,7 @@ public:
* \brief Returns the type of the state
*
*/
const StateType &get_type() const;
const StateType *get_type() const;
/*!
*
......@@ -65,7 +75,7 @@ public:
* \brief Returns the value of the state
*
*/
const EntityValue &get_value() const;
const EntityValue *get_value() const;
/*!
*
......@@ -73,7 +83,7 @@ public:
* \brief Returns the container that contains the state
*
*/
const Container &get_container() const;
const Container *get_container() const;
};
#endif
......@@ -8,44 +8,28 @@
*
*/
//#include "EntityType.hpp"
#include "values/Name.hpp"
#include "ContainerType.hpp"
/*!
*
*\class StateType
*\brief The class that describes the states
*
*/
class StateType : public EntityType{
Name type;
class StateType /*: public EntityType*/ {
private:
Name _name;
ContainerType *_container_type;
public :
/*!
*
*\fn get_entity_type
*\brief Return the type of the entity
*
*/
const EntityType& get_entity_type() const;
/*!
*
*\fn set_type
*\brief Set the type of the state
*\param type The new type of the state
*
*/
void set_entity_type(const EntityType &type);
/*!
*
*\fn has_same_type
*\brief Return if the type of the state is equal to the type of the parameter
*\param A container type
*
*/
bool has_same_type(const EntityType &type) const;
StateType(const Name &name, ContainerType *container_type);
Name get_name() const;
const ContainerType *get_container_type() const;
};
#endif
......@@ -11,7 +11,7 @@
*/
#include <sstream>
#include "value.hpp"
#include "Value.hpp"
/*!
*
......
......@@ -24,22 +24,22 @@ std::string Date::to_string() const{
return oss.str();
}
bool Date::operator<(Date &d) const{
bool Date::operator<(const Date &d) const{
return (_value < d._value);
}
bool Date::operator>(Date &d) const{
bool Date::operator>(const Date &d) const{
return (_value > d._value);
}
bool Date::operator<=(Date &d) const{
bool Date::operator<=(const Date &d) const{
return (_value <= d._value);
}
bool Date::operator>=(Date &d) const{
bool Date::operator>=(const Date &d) const{
return (_value >= d._value);
}
double Date::operator-(Date &d) const{
double Date::operator-(const Date &d) const{
return (_value - d._value);
}
......@@ -10,7 +10,7 @@
*
*/
#include "value.hpp"
#include "Value.hpp"
#include <sstream>
#include <cstdio>
......@@ -53,11 +53,11 @@ public:
*/
std::string to_string() const;
bool operator<(Date &) const;
bool operator>(Date &) const;
bool operator<=(Date &) const;
bool operator>=(Date &) const;
double operator-(Date &) const;
bool operator<(const Date &) const;
bool operator>(const Date &) const;
bool operator<=(const Date &) const;
bool operator>=(const Date &) const;
double operator-(const Date &) const;
};
#endif // DATE_HPP
......@@ -10,7 +10,7 @@
*
*/
#include "value.hpp"
#include "Value.hpp"
#include <sstream>
#include <cstdio>
......
......@@ -14,7 +14,7 @@
#include <iostream>
#include <fstream>
#include <cstdio>
#include "value.hpp"
#include "Value.hpp"
/*!
*
......
......@@ -12,7 +12,7 @@
#include <sstream>
#include <cstdio>
#include "value.hpp"
#include "Value.hpp"
/*!
*
......
......@@ -16,6 +16,11 @@ Name::Name(name_only_t name_only, std::string name) {
Name::Name(alias_only_t alias_only, std::string alias) {
_name.clear();
_alias = alias;
}
Name::Name(Name &name) {
_name = name._name;
_alias = name._alias;
}
std::string Name::to_string() const {
......
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