Teamcenter C++ API Reference  2312
Public Types | Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
Teamcenter::ErrorMap Class Reference

An indexed map of errors. Filters out ITK_ok errors on addition. ErrorMap implements a set-based style of error reporting, very different from Teamcenter ITK-style error stacks. We expect clients to return ErrorMaps from set-based functions, and the class is optimized for this use case. Clietns will associate each Error with an array index identifier. The ErrorMap class conceptually stacks up Errors under these index identifiers, returning the most recent. Clients may need to re-map index identifiers as they pass ErrorMaps up the call chain. More...

#include <error_map.hxx>

Public Types

typedef StdSmMap< size_t,
Error >::Map::const_iterator 
const_iterator
 
typedef StdSmMap< size_t,
Error >::Map::iterator 
iterator
 stl-like iterators. More...
 
typedef size_t key_type
 stl-like typedefs. More...
 
typedef Error mapped_type
 
typedef StdSmMap< size_t,
Error >::Map::value_type 
value_type
 

Public Member Functions

ErrorMapadd (size_t id, Error const &error)
 Add an individual error to the error set. Discard all but the most recent error. More...
 
ErrorMapadd (size_t id, int ifail)
 Add an individual integer fail code to the error set. Handle the ifail by taking ownership of (clearing) the current error stack. More...
 
ErrorMapadd (size_t id, IFail const &ifail)
 Add an individual IFail to the error set. Handle the ifail by taking ownership of (clearing) the current error stack. More...
 
ErrorMapadd (size_t id, status_t const &status)
 Add an individual status_t to the error set. Handle the ifail by taking ownership of (clearing) the current error stack. More...
 
iterator begin ()
 stl-like iteration. More...
 
const_iterator begin () const
 
bool empty () const
 stl-like is map empty? More...
 
iterator end ()
 
const_iterator end () const
 
 ErrorMap ()
 Empty set - no errors. More...
 
 ErrorMap (ErrorMap const &)
 
iterator find (size_t id)
 stl-like map lookup. More...
 
const_iterator find (size_t id) const
 
ErrorMapoperator+= (ErrorMap const &right)
 Update with the latest errors. More recent (right) errors, replace older (this) errors. More...
 
ErrorMapoperator= (ErrorMap const &)
 
size_t size () const
 stl-like map size. More...
 

Private Types

typedef StdSmMap< size_t,
Error >::Map 
StdErrorMap
 

Private Member Functions

StdErrorMapensureMap ()
 Ensure m_map is allocated, and return a reference.s. More...
 

Private Attributes

StdErrorMap m_emptyMap
 
shared_ptr< StdErrorMapm_map
 

Detailed Description

An indexed map of errors. Filters out ITK_ok errors on addition. ErrorMap implements a set-based style of error reporting, very different from Teamcenter ITK-style error stacks. We expect clients to return ErrorMaps from set-based functions, and the class is optimized for this use case. Clietns will associate each Error with an array index identifier. The ErrorMap class conceptually stacks up Errors under these index identifiers, returning the most recent. Clients may need to re-map index identifiers as they pass ErrorMaps up the call chain.

sample:

ErrorMap errors;
errors += func1( args... );
errors += func2( args... );
return errors;
Note
A std::map<size_t, Error> almost does the trick, however we want to introduce some new functions of our own. Since we should not derive from std::map, let's wrap it instead.

Definition at line 165 of file error_map.hxx.

Member Typedef Documentation

typedef StdSmMap< size_t, Error >::Map::const_iterator Teamcenter::ErrorMap::const_iterator

Definition at line 198 of file error_map.hxx.

typedef StdSmMap< size_t, Error >::Map::iterator Teamcenter::ErrorMap::iterator

stl-like iterators.

Definition at line 197 of file error_map.hxx.

stl-like typedefs.

Definition at line 192 of file error_map.hxx.

Definition at line 193 of file error_map.hxx.

typedef StdSmMap< size_t, Error >::Map Teamcenter::ErrorMap::StdErrorMap
private

Definition at line 216 of file error_map.hxx.

typedef StdSmMap< size_t, Error >::Map::value_type Teamcenter::ErrorMap::value_type

Definition at line 194 of file error_map.hxx.

Constructor & Destructor Documentation

Teamcenter::ErrorMap::ErrorMap ( )
inline

Empty set - no errors.

Definition at line 323 of file error_map.hxx.

Teamcenter::ErrorMap::ErrorMap ( ErrorMap const &  errorMap)
inline

Definition at line 329 of file error_map.hxx.

Member Function Documentation

ErrorMap& Teamcenter::ErrorMap::add ( size_t  id,
Error const &  error 
)

Add an individual error to the error set. Discard all but the most recent error.

ErrorMap & Teamcenter::ErrorMap::add ( size_t  id,
int  ifail 
)
inline

Add an individual integer fail code to the error set. Handle the ifail by taking ownership of (clearing) the current error stack.

Definition at line 344 of file error_map.hxx.

ErrorMap & Teamcenter::ErrorMap::add ( size_t  id,
IFail const &  ifail 
)
inline

Add an individual IFail to the error set. Handle the ifail by taking ownership of (clearing) the current error stack.

Definition at line 349 of file error_map.hxx.

ErrorMap & Teamcenter::ErrorMap::add ( size_t  id,
status_t const &  status 
)
inline

Add an individual status_t to the error set. Handle the ifail by taking ownership of (clearing) the current error stack.

Definition at line 354 of file error_map.hxx.

ErrorMap::iterator Teamcenter::ErrorMap::begin ( )
inline

stl-like iteration.

Definition at line 374 of file error_map.hxx.

ErrorMap::const_iterator Teamcenter::ErrorMap::begin ( ) const
inline

Definition at line 390 of file error_map.hxx.

bool Teamcenter::ErrorMap::empty ( ) const
inline

stl-like is map empty?

Definition at line 366 of file error_map.hxx.

ErrorMap::iterator Teamcenter::ErrorMap::end ( )
inline

Definition at line 382 of file error_map.hxx.

ErrorMap::const_iterator Teamcenter::ErrorMap::end ( ) const
inline

Definition at line 398 of file error_map.hxx.

StdErrorMap& Teamcenter::ErrorMap::ensureMap ( )
inlineprivate

Ensure m_map is allocated, and return a reference.s.

iterator Teamcenter::ErrorMap::find ( size_t  id)

stl-like map lookup.

const_iterator Teamcenter::ErrorMap::find ( size_t  id) const
ErrorMap& Teamcenter::ErrorMap::operator+= ( ErrorMap const &  right)

Update with the latest errors. More recent (right) errors, replace older (this) errors.

ErrorMap & Teamcenter::ErrorMap::operator= ( ErrorMap const &  errorMap)
inline

Definition at line 335 of file error_map.hxx.

size_t Teamcenter::ErrorMap::size ( ) const
inline

stl-like map size.

Definition at line 359 of file error_map.hxx.

Member Data Documentation

StdErrorMap Teamcenter::ErrorMap::m_emptyMap
private

Empty map for iteration when m_map is unallocated.

Note
A class-static empty error map fails to link on wnti32 when used in inline functions (error LNK2001; 2006/04/18). And we prefer the inlining over space, especially for end() (think loops).

Definition at line 231 of file error_map.hxx.

shared_ptr< StdErrorMap > Teamcenter::ErrorMap::m_map
private

Owned errors are stored in this map.

Note
Pointer so that we can get cheap copies (return ErrorMap; is common usage).
Allocated when first needed. Keep empty ErrorMap cheap.

Definition at line 225 of file error_map.hxx.


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