Scanframe Modular Application 0.1.0
Loading...
Searching...
No Matches
sf::TTypedList< T, S > Class Template Referenceabstract

Interface class for managing an indexed lists. Sends out events when about to change and when changed using sf::TClosure instances. More...

#include <TTypedList.h>

Collaboration diagram for sf::TTypedList< T, S >:

Public Types

typedef ssize_t index_type
 Type of the indices used by this class.
 
typedef T value_type
 Type of the stored values.
 

Public Member Functions

 TTypedList ()=default
 Default constructor.
 
virtual ~TTypedList ()=default
 Virtual destructor.
 
virtual ssize_t add (const value_type &value)
 Adds an integer to the end of the list.
 
void assign (std::initializer_list< value_type > list)
 Assigns a list of values to the list.
 
void assign (const TTypedList &other)
 Assign the values from the other typed list.
 
virtual void exchange (index_type from_index, index_type to_index)
 Swap underling index positions.
 
void clear ()
 Clears the all items from the store.
 
virtual void remove (index_type index, index_type sz)
 Removes the item at the position given by the index argument. When the underlying list is static do not implement.
 
bool isEqual (const TTypedList &other) const
 Compares the other list with this one.
 
bool operator== (const TTypedList &other) const
 Equal operator calling isEqual().
 
bool operator!= (const TTypedList &other) const
 Equal operator calling isEqual().
 
index_type indexOf (const value_type &value) const
 Gets the found index of the given value in the list.
 
void set (index_type index, const value_type &value)
 Sets an entry value using the given index position.
 
value_type get (index_type index) const
 Gets the const entry reference from the given index position.
 
value_type operator[] (index_type index) const
 Const array operator calling get().
 
virtual index_type size () const =0
 Gets the size of the underlying data store.
 
virtual void resize (index_type)
 Resizes the underlying store. When the store is static do not override it.
 
toString (const S &separator={}) const
 Gets the values as a string separated by the given separator.
 
void fromString (const S &str, value_type def={}, const S &separator={})
 Gets the values as a string separated by the given separator.
 
virtual void beginChange ()
 Enables to track when the list of strings is changing. Can be overloaded when needed for change event optimization.
 
virtual void endChange ()
 Enables the to keep track of when the list has finished changing. Can be overloaded when needed for change event optimization.
 

Public Attributes

TClosure< void, void * > onChanging
 Event callback function for when a change is about to happen.
 
TClosure< void, void * > onChanged
 Event callback function for when a change is done.
 

Static Public Attributes

static constexpr index_type npos {-1}
 Value for no index position.
 

Protected Member Functions

void checkIndex (index_type index) const
 Checks the validity of the passed index and when not valid throws an exception.
 
virtual value_type store (index_type index, const value_type *value=nullptr)=0
 Handles Accesses the actual store.
 
void setHexadecimal (bool flag)
 Enables integral types as hexadecimals in the string from toString() function.
 

Detailed Description

template<typename T, typename S = std::string>
class sf::TTypedList< T, S >

Interface class for managing an indexed lists. Sends out events when about to change and when changed using sf::TClosure instances.

Template Parameters
TType of the indexed values.
SType of the string the value is converted.

Member Typedef Documentation

◆ index_type

template<typename T , typename S = std::string>
typedef ssize_t sf::TTypedList< T, S >::index_type

Type of the indices used by this class.

◆ value_type

template<typename T , typename S = std::string>
typedef T sf::TTypedList< T, S >::value_type

Type of the stored values.

Constructor & Destructor Documentation

◆ TTypedList()

template<typename T , typename S = std::string>
sf::TTypedList< T, S >::TTypedList ( )
default

Default constructor.

◆ ~TTypedList()

template<typename T , typename S = std::string>
virtual sf::TTypedList< T, S >::~TTypedList ( )
virtualdefault

Virtual destructor.

Member Function Documentation

◆ add()

template<typename T , typename S = std::string>
virtual ssize_t sf::TTypedList< T, S >::add ( const value_type value)
virtual

Adds an integer to the end of the list.

Parameters
valueValue added to the list.
Returns
Index of the added value.

◆ assign() [1/2]

template<typename T , typename S = std::string>
void sf::TTypedList< T, S >::assign ( const TTypedList< T, S > &  other)

Assign the values from the other typed list.

◆ assign() [2/2]

template<typename T , typename S = std::string>
void sf::TTypedList< T, S >::assign ( std::initializer_list< value_type list)

Assigns a list of values to the list.

◆ beginChange()

template<typename T , typename S = std::string>
virtual void sf::TTypedList< T, S >::beginChange ( )
virtual

Enables to track when the list of strings is changing. Can be overloaded when needed for change event optimization.

◆ checkIndex()

template<typename T , typename S = std::string>
void sf::TTypedList< T, S >::checkIndex ( index_type  index) const
protected

Checks the validity of the passed index and when not valid throws an exception.

Parameters
indexIndex to check.
Exceptions
std::out_of_range

◆ clear()

template<typename T , typename S = std::string>
void sf::TTypedList< T, S >::clear ( )

Clears the all items from the store.

◆ endChange()

template<typename T , typename S = std::string>
virtual void sf::TTypedList< T, S >::endChange ( )
virtual

Enables the to keep track of when the list has finished changing. Can be overloaded when needed for change event optimization.

◆ exchange()

template<typename T , typename S = std::string>
virtual void sf::TTypedList< T, S >::exchange ( index_type  from_index,
index_type  to_index 
)
virtual

Swap underling index positions.

◆ fromString()

template<typename T , typename S = std::string>
void sf::TTypedList< T, S >::fromString ( const S &  str,
value_type  def = {},
const S &  separator = {} 
)

Gets the values as a string separated by the given separator.

Parameters
strSeparated string containing the string values.
separatorBetween the converted values in the string. Defaults to the comma character.
defDefault value.

◆ get()

template<typename T , typename S = std::string>
value_type sf::TTypedList< T, S >::get ( index_type  index) const

Gets the const entry reference from the given index position.

◆ indexOf()

template<typename T , typename S = std::string>
index_type sf::TTypedList< T, S >::indexOf ( const value_type value) const

Gets the found index of the given value in the list.

Returns
npos (-1) when not found.

◆ isEqual()

template<typename T , typename S = std::string>
bool sf::TTypedList< T, S >::isEqual ( const TTypedList< T, S > &  other) const

Compares the other list with this one.

Returns
true when the same.

◆ operator!=()

template<typename T , typename S = std::string>
bool sf::TTypedList< T, S >::operator!= ( const TTypedList< T, S > &  other) const

Equal operator calling isEqual().

◆ operator==()

template<typename T , typename S = std::string>
bool sf::TTypedList< T, S >::operator== ( const TTypedList< T, S > &  other) const

Equal operator calling isEqual().

◆ operator[]()

template<typename T , typename S = std::string>
value_type sf::TTypedList< T, S >::operator[] ( index_type  index) const

Const array operator calling get().

◆ remove()

template<typename T , typename S = std::string>
virtual void sf::TTypedList< T, S >::remove ( index_type  index,
index_type  sz 
)
virtual

Removes the item at the position given by the index argument. When the underlying list is static do not implement.

Parameters
indexIndicates entry index to be removed.
szAmount of entries to remove.

Reimplemented in sf::InformationIdList.

◆ resize()

template<typename T , typename S = std::string>
virtual void sf::TTypedList< T, S >::resize ( index_type  )
virtual

Resizes the underlying store. When the store is static do not override it.

Reimplemented in sf::InformationIdList.

◆ set()

template<typename T , typename S = std::string>
void sf::TTypedList< T, S >::set ( index_type  index,
const value_type value 
)

Sets an entry value using the given index position.

◆ setHexadecimal()

template<typename T , typename S = std::string>
void sf::TTypedList< T, S >::setHexadecimal ( bool  flag)
protected

Enables integral types as hexadecimals in the string from toString() function.

Parameters
flagtrue for using hexadecimals.

◆ size()

template<typename T , typename S = std::string>
virtual index_type sf::TTypedList< T, S >::size ( ) const
pure virtual

Gets the size of the underlying data store.

Implemented in sf::InformationIdList, and sf::VariableIdList.

◆ store()

template<typename T , typename S = std::string>
virtual value_type sf::TTypedList< T, S >::store ( index_type  index,
const value_type value = nullptr 
)
protectedpure virtual

Handles Accesses the actual store.

Parameters
indexIndex to access.
valueValue pointer to write when not null.
Returns
Reference to entry in the store.

Implemented in sf::InformationIdList, and sf::VariableIdList.

◆ toString()

template<typename T , typename S = std::string>
S sf::TTypedList< T, S >::toString ( const S &  separator = {}) const

Gets the values as a string separated by the given separator.

Parameters
separatorBetween the converted values in the string. Defaults to the comma character
Returns
String representation.

Member Data Documentation

◆ npos

template<typename T , typename S = std::string>
constexpr index_type sf::TTypedList< T, S >::npos {-1}
staticconstexpr

Value for no index position.

◆ onChanged

template<typename T , typename S = std::string>
TClosure<void, void*> sf::TTypedList< T, S >::onChanged

Event callback function for when a change is done.

◆ onChanging

template<typename T , typename S = std::string>
TClosure<void, void*> sf::TTypedList< T, S >::onChanging

Event callback function for when a change is about to happen.


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