Protected Member Functions | Friends | List of all members
icl_core::ExpectedTypeIs< T > Struct Template Reference

#include <ExpectedType.h>

Inheritance diagram for icl_core::ExpectedTypeIs< T >:
Inheritance graph
[legend]

Protected Member Functions

bool equals (const ExpectedType *other) const
 

Friends

struct ExpectedType
 

Additional Inherited Members

- Public Types inherited from icl_core::ExpectedType
typedef boost::shared_ptr< const ExpectedTypePtr
 
- Public Member Functions inherited from icl_core::ExpectedType
template<typename T >
bool is () const
 Check if an actual type equals this expected type. More...
 
bool operator!= (const ExpectedType &other) const
 Directly compare two ExpectedType objects. More...
 
bool operator== (const ExpectedType &other) const
 Directly compare two ExpectedType objects. More...
 
virtual ~ExpectedType ()
 

Detailed Description

template<typename T>
struct icl_core::ExpectedTypeIs< T >

An object bearing the information that the expected type of some operation is T. If you have a complex function which will return an object of a certain type depending on runtime circumstances, you can write another function that will quickly inspect the parameters to provide information on the type returned by the complex function. Usage example:

class Foo : public BaseClass { ... };
class Bar : public BaseClass { ... };
class ComplexOp
{
...
// The complex operation takes a long time and returns either a
// Foo or a Bar depending on the parameter
BaseClass::Ptr complexOperation(int parameter);
// Informs the user quickly what type will be provided.
ExpectedType::Ptr complexOperationResult(int parameter)
{
if (parameter > 0) return ExpectedType::Ptr(new ExpectedTypeIs<Foo>);
else return ExpectedType::Ptr(new ExpectedTypeIs<Bar>);
}
};
See also
ExpectedType for how to use the expected type result.

Definition at line 33 of file ExpectedType.h.

Member Function Documentation

template<typename T >
bool icl_core::ExpectedTypeIs< T >::equals ( const ExpectedType other) const
inlineprotectedvirtual

Implements icl_core::ExpectedType.

Definition at line 115 of file ExpectedType.h.

Friends And Related Function Documentation

template<typename T >
friend struct ExpectedType
friend

Definition at line 119 of file ExpectedType.h.


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


fzi_icl_core
Author(s):
autogenerated on Mon Jun 10 2019 13:17:59