Data Model Description

Defines

MAKE_CLASS_SORT(class_name, att_list)

Create an operator< based on a list of attributes.

MAKE_CLASS_SORT(AbstractClosing, (from, to) )
expands to
public: bool operator<(AbstractClosing const&other) const
 {
   if( safecomp::neq( get_from(), other.get_from() ) )
   {
      if( safecomp::lt( get_from(), other.get_from() ) )
      {
         return true;
      }
      else
      {
         return false;
      }
   }
   if( safecomp::neq( get_to(), other.get_to() ) )
   {
      if( safecomp::lt( get_to() , other.get_to() ) )
      {
         return true;
      }
      else
      {
         return false;
      }
   }
   return false;
}

Parameters:
  • class_name – the name of the class

  • att_list – the list of attributes to sort on

MAKE_DTO_STRUCT(struct_name, att_seq)

allow the declaration of a structure

MAKE_DTO_STRUCT(
    PressDto,
    ( (std::string)(id) )
    ( (unsigned)(pos) )
)
expands to
struct PressDto
{
    std::string id;
    unsigned pos;
};

Remark

these structures are serializable and streamable

See also

details::streamable

Parameters:
  • struct_name – the name of the struct

  • att_seq – the sequence of sequences describing the attribute

MAKE_DTO_ENUM

allow the declaration of an enum

MAKE_DTO_ENUM(
    //Name
    EnumDto,
    //Values
    VAL_1,
    VAL_2,
    VAL_3
)

Remark

it is just an alias for BOOST_DEFINE_ENUM

Remark

these structures are serializable and streamable

MAKE_ATT(att_desc)

Generate the declaration and every set / get for basic attribute.

MAKE_ATT( (std::string)(id)("default") )
MAKE_ATT( (float)(contribution) )
expands to
private:
    std::string _id={"default"};
public:
    std::string const &get_id() const { return _id; }
    std::string &get_id() { return _id; }
    void set_id(std::string const &val) { _id = val; }
private:
    float _contribution;
public:
    float &get_contribution() { return _contribution; }
    float const &get_contribution() const { return _contribution; }
    void set_contribution(float const &val) { _contribution = val; }

Parameters:
  • att_desc – sequence describing the attribute : (type)(name)[(default_value)]

MAKE_NON_COPYABLE_ATT(att_desc)

Generate the declaration and every set / get for basic attribute.

MAKE_NON_COPYABLE_ATT( (MyClass)(my_class) )
expands to
private:
    MyClass _my_class;
public:
    MyClass const &get_my_class() const { return _my_class; }
    MyClass &get_my_class() { return _my_class; }

Parameters:
  • att_desc – sequence describing the attribute : (type)(name)[(default_value)]

MAKE_CONST_ATT(att_desc)

Generate the declaration and every get for basic non modifiable attribute.

MAKE_CONST_ATT( (std::vector<std::string>)(ids) )
expands to
private:
    std::vector<std::string> _ids;
public:
    std::vector<std::string> const &get_ids() const { return _ids; }

Parameters:
  • att_desc – sequence describing the attribute : (type)(name)

MAKE_MAP(key, value, name)

Generate an editable attribute std::map<key, value> _name along with its getters.

MAKE_MAP(std::string, int, values)
expands to
private:
 std::map<std::string, int> _values;
public:
 std::map<std::string, int> &get_values()
 {
   return _values;
 }
 std::map<std::string, int> const &get_values() const
 {
   return _values;
 }

Parameters:
  • key – the type of keys

  • value – the type of values

  • name – the name of the attribute

MAKE_SET(value, name)

Generate an editable attribute std::set<value> _name along with its getters.

MAKE_SET(int, values)
expands to
private:
 std::set<int> _values;
public:
 std::set<int> &get_values()
 {
   return _values;
 }
 std::set<int> const &get_values() const
 {
   return _values;
 }

Parameters:
  • value – the type of values

  • name – the name of the attribute

MAKE_STRHASH_MAP(value, name)

Generate an editable attribute std::unordered_map<std::string, value> _name along with its getters.

MAKE_STRHASH_MAP(int, values)
expands to
private:
 std::unordered_map<std::string, int, string_hash, std::equal_to<>>;
public:
 std::unordered_map<std::string, int, string_hash, std::equal_to<>> &get_values()
 {
   return _values;
 }
 std::unordered_map<std::string, int, string_hash, std::equal_to<>> const &get_values() const
 {
   return _values;
 }

See also

string_hash

Parameters:
  • value – the type of values

  • name – the name of the attribute

MAKE_CLASS_REF_ATT(type, name)

Generate an editable attribute type & _name along with its getters.

MAKE_CLASS_REF_ATT(type, obj)
expands to
private:
 type &_obj;
public:
 type &get_obj()
 {
   return _obj;
 }
 type const &get_obj() const
 {
   return _obj;
 }

Parameters:
  • type – the class name

  • name – the name of the attribute

MAKE_CLASS_CONSTREF_ATT(type, name)

Generate a read only attribute type const & _name along with its getters.

MAKE_CLASS_CONSTREF_ATT(type, obj)
expands to
private:
 type const &_obj;
public:
 type const &get_obj() const
 {
   return _obj;
 }

Parameters:
  • type – the class name

  • name – the name of the attribute

MAKE_CLASS_ATT(const_att_seq, editable_att_seq)

Generate every set / get for basic attributes.

MAKE_CLASS_ATT(
    //non editable attributes
    ( (std::string)(id) ),
    //editable attributes
    ( (unsigned)(x) )
    ( (unsigned)(pos) )
)
expands to
private:
    std::string _id;
public:
    std::string const &get_id() const { return _id; }
private:
    unsigned _x;
public:
    void set_x(unsigned p) { _x = p; }
    unsigned &get_x() { return _x; }
    unsigned get_x() const { return _x; }
private:
    unsigned _pos;
public:
    void set_pos(unsigned p) { _pos = p; }
    unsigned &get_pos() { return _pos; }
    unsigned get_pos() const { return _pos; }

Parameters:
  • const_att_seq – sequence of non editable attributes

  • editable_att_seq – sequence of editable attributes

Variables

constexpr int N_SEC_IN_DAY = 86400

Constant equals to the number of seconds in a day.

constexpr int N_SEC_IN_HOUR = 3600

Constant equals to the number of seconds in an hour.

constexpr int N_MILLISEC_IN_HOUR = 3600000

Constant equals to the number of seconds in an hour.

struct string_hash
#include <hash.hh>

heterogenous lookup for string

Public Types

using is_transparent = void

Public Functions

inline size_t operator()(const char *txt) const
inline size_t operator()(std::string_view txt) const
inline size_t operator()(const std::string &txt) const