template<typename T, typename A, typename S>
class walberla::selectable::SelectableObject< T, A, S >
Abstract base class for storing and selecting objects of type T which are attached with selection attributes of type A.
The sole purpose of this class is to store selectable objects of type T, meaning objects which are attached with additional selection attributes of type A, in order to later retrieve only those objects which match certain requested attributes. For the retrieval (see functions "get") a selection object of type S is used (type S may or may not be equal to type A).
Requirements for type A:
- objects of type A must be comparable with operator "!="
- A must implement operator "<<" for output via a std::ostream object
Additionally, it must be possible to store objects of both types T and A in a std::vector.
Objects can be added by calling the function "add" (for every object that is added an identifier string can be provided) and be retrieved by calling "get". For additional information refer to the documentation of these functions.
Every class that derives from SelectableObject must implement the function
void select( std::vector< size_t >& index,
const S& selector )
const
After returning from the call to this function, the vector "index" must contain the index of every object in "attributes_" that matches with the provided selector "selector" (for an actual implementation of SelectableObject see "SetSelectableObject.h").
|
class | const_iterator |
|
class | iterator |
|
std::vector< T > | object_ |
|
std::vector< std::string > | identifier_ |
|
std::vector< A > | attributes_ |
|
virtual | ~SelectableObject ()=default |
|
void | add (const T &object, const A &attributes, const std::string &identifier=std::string()) |
| This function is used to add an object together with its selection attributes stored in "attributes". More...
|
|
iterator | begin () |
|
const_iterator | begin () const |
|
iterator | end () |
|
const_iterator | end () const |
|
size_t | getNumberOfMatching (const S &selector) const |
| Returns the number of objects matching the specified "selector". More...
|
|
size_t | get (T &object, const S &selector) const |
| This function can be used to retrieve the one object whose attributes match with "selector". More...
|
|
void | get (std::vector< T > &object, const S &selector) const |
| This function can be used to retrieve all objects whose attributes match with the selector "selector". More...
|
|
size_t | get (T &object, std::string &identifier, const S &selector) const |
| This function can be used to retrieve the one object whose attributes match with "selector". More...
|
|
void | get (std::vector< T > &object, std::vector< std::string > &identifier, const S &selector) const |
| This function can be used to retrieve all objects whose attributes match with the selector "selector". More...
|
|
T * | getUnique (const S &selector) |
| Non-const version of getUnique(). More...
|
|
const T * | getUnique (const S &selector) const |
| This function can be used to retrieve a pointer (!) to the object whose attributes match with "selector". More...
|
|
T * | getUnique (const S &selector, std::string &identifierOut) |
| Non-const version of getUnique(const S&, std::string& ). More...
|
|
const T * | getUnique (const S &selector, std::string &identifierOut) const |
| This function is similar to getUnique(const S &selector) but takes an additional output parameter identifier, which is set to the string identifier of the selected object, if a non-zero pointer is returned, otherwise the identifier string is not changed. More...
|
|
void | toStream (std::ostream &os) const |
|
std::string | toString () const |
|
size_t | size () const |
|
bool | empty () const |
|
virtual void | select (std::vector< size_t > &index, const S &selector) const =0 |
| Every class that derives from SelectableObject must implement this function. More...
|
|
template<typename T , typename A , typename S >
This function is used to add an object together with its selection attributes stored in "attributes".
Optionally, an identifier string can be provided which is used during output (see "toStream" and "toString"). In debug mode, this function triggers an assertion and fails if another object with the same selection attributes already exists.
template<typename T , typename A , typename S >
This function can be used to retrieve all objects whose attributes match with the selector "selector".
The objects are returned using the provided vector "objects" (this function may return none, exactly one, ore multiple objects depending on "selector" and the actual implementation of the function "select"). Additionally, for every object that is found, its corresponding identifier is also returned via "identifier".
template<typename T , typename A , typename S >
This function can be used to retrieve the one object whose attributes match with "selector".
Depending on "selector" and the actual implementation of the function "select", no object, one object, or multiple objects may be found. If only one object is found, it is returned via the parameter "object". If multiple objects are found, the first object whose attributes match is returned via "object". In any case, the number of objects that match with "selector" is returned by this function - and only if the return value is equal to '1' exactly one object was found and stored in "object".
template<typename T , typename A , typename S >
This function can be used to retrieve the one object whose attributes match with "selector".
Depending on "selector" and the actual implementation of the function "select", no object, one object, or multiple objects may be found. If only one object is found, it is returned via the parameter "object". If multiple objects are found, the first object whose attributes match is returned via "object". In any case, the number of objects that match with "selector" is returned by this function - and only if the return value is equal to '1' exactly one object was found and stored in "object". Additionally, the corresponding identifier is also returned via the parameter "identifier".
template<typename T , typename A , typename S >
This function can be used to retrieve a pointer (!) to the object whose attributes match with "selector".
Depending on "selector" and the actual implementation of the function "select", no object, one object, or multiple objects may be found. If no objects or multiple objects are found, NULL is returned. Attention: The pointer may get invalidated by subsequent calls to the member function "add".