Public Types | Public Member Functions | Protected Member Functions
icl_core::ExpectedType Struct Reference

#include <ExpectedType.h>

Inheritance diagram for icl_core::ExpectedType:
Inheritance graph
[legend]

List of all members.

Public Types

typedef boost::shared_ptr
< const ExpectedType
Ptr

Public Member Functions

template<typename T >
bool is () const
 Check if an actual type equals this expected type.
bool operator!= (const ExpectedType &other) const
 Directly compare two ExpectedType objects.
bool operator== (const ExpectedType &other) const
 Directly compare two ExpectedType objects.
virtual ~ExpectedType ()

Protected Member Functions

virtual bool equals (const ExpectedType *other) const =0

Detailed Description

An object bearing information about the type expected from some operation. If a complex function call will return an object of a certain type depending on runtime circumstances, it may not always be desirable, or even possible, to start the operation, wait for the returned object, and perform a dynamic_cast to see what it is. Instead, the class can provide another function which tells you which datatype to expect given the parameters you would pass to the complex function. This can be used as follows:

  class Foo : public BaseClass { ... };
  class Bar : public BaseClass { ... };
  ExpectedType::Ptr et = complex_op.expectedReturnType(params);
  if (et->is<Foo>()) std::cout << "Operation will return a Foo object\n";
  if (et->is<Bar>()) std::cout << "Operation will return a Bar object\n";
  BaseClass::Ptr result = complex_op.execute(params);
  // Wait some time...
  std::cout << result << "\n"; // Prints stuff for Foo or Bar, depending on result
See also:
ExpectedTypeIs<T> for how to write an expectedReturnType function as used in the code example.

Definition at line 58 of file ExpectedType.h.


Member Typedef Documentation

typedef boost::shared_ptr<const ExpectedType> icl_core::ExpectedType::Ptr

Definition at line 61 of file ExpectedType.h.


Constructor & Destructor Documentation

virtual icl_core::ExpectedType::~ExpectedType ( ) [inline, virtual]

Definition at line 63 of file ExpectedType.h.


Member Function Documentation

virtual bool icl_core::ExpectedType::equals ( const ExpectedType other) const [protected, pure virtual]
template<typename T >
bool icl_core::ExpectedType::is ( ) const [inline]

Check if an actual type equals this expected type.

Definition at line 66 of file ExpectedType.h.

bool icl_core::ExpectedType::operator!= ( const ExpectedType other) const [inline]

Directly compare two ExpectedType objects.

Definition at line 75 of file ExpectedType.h.

bool icl_core::ExpectedType::operator== ( const ExpectedType other) const [inline]

Directly compare two ExpectedType objects.

Definition at line 69 of file ExpectedType.h.


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


fzi_icl_core
Author(s):
autogenerated on Tue Aug 8 2017 02:28:05