iv::Sub< Type, LocalItems, LocalStorage > Class Template Reference

#include <Sub.hpp>

Public Member Functions

 Sub ()
 
 ~Sub ()
 
 Sub (Sub const &src)
 
Suboperator= (Sub const &src)
 
void clear ()
 Removes all content, effectively resetting it to default values. More...
 
template<class SubType >
SubType & operator[] (SubId< Type, SubType > const &id)
 

Detailed Description

template<class Type, size_t LocalItems = 0, size_t LocalStorage = 0>
class iv::Sub< Type, LocalItems, LocalStorage >

\ingroup ModelTools
\brief Allow other modules to have something like a private member variables in your class.

Class that can contain sub-data:

// in .hpp
class Item
{
public:
iv::Sub< Item > sub; //< This says that Item must have static member SubdirectoryInst of type SubDirectory.
static iv::SubDirectory SubDirectoryInst;
};
// in .cpp
iv::SubDirectory Item::SubDirectoryInst;

Defining data that can be added:

// in .hpp
struct ExtraValue
{
int extra_value;
};
// in .cpp
const iv::SubId< Item, ExtraValue > ExtraValue::Id;

Accessing data:

Item item;
ExtraValue & data = item.sub[ ExtraValue::Id ];
data.extra_value = 125;

Definition at line 91 of file Sub.hpp.

Constructor & Destructor Documentation

◆ Sub() [1/2]

template<class SubType , size_t LocalItems, size_t LocalStorage>
iv::Sub< SubType, LocalItems, LocalStorage >::Sub

Definition at line 121 of file Sub.inl.

◆ ~Sub()

template<class SubType , size_t LocalItems, size_t LocalStorage>
iv::Sub< SubType, LocalItems, LocalStorage >::~Sub

Definition at line 130 of file Sub.inl.

◆ Sub() [2/2]

template<class Type , size_t LocalItems, size_t LocalStorage>
iv::Sub< Type, LocalItems, LocalStorage >::Sub ( Sub< Type, LocalItems, LocalStorage > const &  src)

Definition at line 281 of file Sub.inl.

Member Function Documentation

◆ operator=()

template<class Type , size_t LocalItems, size_t LocalStorage>
Sub< Type, LocalItems, LocalStorage > & iv::Sub< Type, LocalItems, LocalStorage >::operator= ( Sub< Type, LocalItems, LocalStorage > const &  src)

Definition at line 301 of file Sub.inl.

◆ clear()

template<class SubType , size_t LocalItems, size_t LocalStorage>
void iv::Sub< SubType, LocalItems, LocalStorage >::clear

Removes all content, effectively resetting it to default values.

Definition at line 152 of file Sub.inl.

◆ operator[]()

template<class Type , size_t LocalItems, size_t LocalStorage>
template<class SubType >
SubType & iv::Sub< Type, LocalItems, LocalStorage >::operator[] ( SubId< Type, SubType > const &  id)

Definition at line 201 of file Sub.inl.


The documentation for this class was generated from the following files: