SmartSoft Component-Developer API
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
Smart::IUniversalId< IdType > Class Template Referenceabstract

A template class providing an interface for a universal identifier. More...

#include <smartIUniversalId_T.h>

Public Member Functions

 IUniversalId ()
 Default constructor. More...
 
 IUniversalId (const std::string &s_id)
 String constructor. More...
 
virtual ~IUniversalId ()=default
 Default destructor. More...
 
virtual operator std::string () const
 conversion operator to std::string More...
 
virtual IUniversalIdoperator= (const std::string &id)
 assignment operator from std::string More...
 
virtual bool operator== (const IUniversalId &id) const
 equality comparison operator More...
 
virtual bool operator!= (const IUniversalId &id) const
 inequality comparison operator More...
 
virtual bool operator< (const IUniversalId &id) const
 smaller comparison operator More...
 
virtual bool operator> (const IUniversalId &id) const
 greater comparison operator More...
 
virtual bool operator<= (const IUniversalId &id) const
 smaller-or-equals comparison operator More...
 
virtual bool operator>= (const IUniversalId &id) const
 greater-or-equals comparison operator More...
 

Protected Member Functions

virtual IdType generateNewId ()=0
 generate a new identifier More...
 
virtual std::string to_string (const IdType &id) const =0
 convert the plaform-specific identifier into a std::string More...
 
virtual IdType from_string (const std::string &s_id) const =0
 convert an std::string into the platform-specific id representation. More...
 

Protected Attributes

IdType _id
 internal (platform-specific) identifier More...
 

Detailed Description

template<class IdType>
class Smart::IUniversalId< IdType >

A template class providing an interface for a universal identifier.

Universal identifiers are typically platform-specific and need to be implemented for each middleware individually. This template class defines the required interface for a wrapper class of an unique identifier.

Constructor & Destructor Documentation

◆ IUniversalId() [1/2]

template<class IdType >
Smart::IUniversalId< IdType >::IUniversalId ( )
inline

Default constructor.

In your derived constructor, please call _id = generateNewId();. This ensures that each new instance of IUniversalId gets a new id.

◆ IUniversalId() [2/2]

template<class IdType >
Smart::IUniversalId< IdType >::IUniversalId ( const std::string &  s_id)
inline

String constructor.

This constructor used the string representation to create a new id. Please call _id = from_string(s_id); in your derived constructor to convert the string into the id.

Parameters
s_idstring representation of the id

◆ ~IUniversalId()

template<class IdType >
virtual Smart::IUniversalId< IdType >::~IUniversalId ( )
virtualdefault

Default destructor.

Member Function Documentation

◆ from_string()

template<class IdType >
virtual IdType Smart::IUniversalId< IdType >::from_string ( const std::string &  s_id) const
protectedpure virtual

convert an std::string into the platform-specific id representation.

Provide a platform-specific implementation of converting string into the platform-specific id representation. This conversion method should not change the internal value of this class.

Parameters
s_idthe platform-specific id representation
Returns
the string representation of the id

◆ generateNewId()

template<class IdType >
virtual IdType Smart::IUniversalId< IdType >::generateNewId ( )
protectedpure virtual

generate a new identifier

Provide a platform-specific implementation of generating a new identifier. Typical implementations are incrementing an identifier or generating a random number. This method is only used internally.

◆ operator std::string()

template<class IdType >
virtual Smart::IUniversalId< IdType >::operator std::string ( ) const
inlinevirtual

conversion operator to std::string

◆ operator!=()

template<class IdType >
virtual bool Smart::IUniversalId< IdType >::operator!= ( const IUniversalId< IdType > &  id) const
inlinevirtual

inequality comparison operator

◆ operator<()

template<class IdType >
virtual bool Smart::IUniversalId< IdType >::operator< ( const IUniversalId< IdType > &  id) const
inlinevirtual

smaller comparison operator

◆ operator<=()

template<class IdType >
virtual bool Smart::IUniversalId< IdType >::operator<= ( const IUniversalId< IdType > &  id) const
inlinevirtual

smaller-or-equals comparison operator

◆ operator=()

template<class IdType >
virtual IUniversalId& Smart::IUniversalId< IdType >::operator= ( const std::string &  id)
inlinevirtual

assignment operator from std::string

◆ operator==()

template<class IdType >
virtual bool Smart::IUniversalId< IdType >::operator== ( const IUniversalId< IdType > &  id) const
inlinevirtual

equality comparison operator

◆ operator>()

template<class IdType >
virtual bool Smart::IUniversalId< IdType >::operator> ( const IUniversalId< IdType > &  id) const
inlinevirtual

greater comparison operator

◆ operator>=()

template<class IdType >
virtual bool Smart::IUniversalId< IdType >::operator>= ( const IUniversalId< IdType > &  id) const
inlinevirtual

greater-or-equals comparison operator

◆ to_string()

template<class IdType >
virtual std::string Smart::IUniversalId< IdType >::to_string ( const IdType &  id) const
protectedpure virtual

convert the plaform-specific identifier into a std::string

Provide a platform-specific implementation of converting the identifier into a string. This conversion method should not change the internal value of this class.

Parameters
idthe platform-specific id representation
Returns
the string representation of the id

Member Data Documentation

◆ _id

template<class IdType >
IdType Smart::IUniversalId< IdType >::_id
protected

internal (platform-specific) identifier


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