Templatious
 All Classes Functions Pages
Public Member Functions | List of all members
templatious::VirtualMatchFunctor Struct Referenceabstract

#include <VirtualMatchFunctor.hpp>

Inheritance diagram for templatious::VirtualMatchFunctor:
templatious::DynamicVMatchFunctor templatious::VirtualMatchFunctorVImpl< StoragePolicy, Args >

Public Member Functions

virtual bool tryMatch (VirtualPack &p)=0
 
virtual bool tryMatch (const VirtualPack &p)=0
 
virtual bool tryMatch (VirtualPack &p) const =0
 
virtual bool tryMatch (const VirtualPack &p) const =0
 
virtual void operator() (VirtualPack &p)
 
virtual void operator() (const VirtualPack &p)
 
virtual void operator() (VirtualPack &p) const
 
virtual void operator() (const VirtualPack &p) const
 

Detailed Description

Main purpose of this class is to match virtual packs to functions by their types at runtime with typesafety.

Member Function Documentation

virtual void templatious::VirtualMatchFunctor::operator() ( VirtualPack p)
inlinevirtual

Match VirtualPack. Throws an exception if pack couldn't be matched.

Parameters
[in]pVirtual pack to match.

Example:

auto vmf = SF::virtualMatchFunctorPtr(
SF::virtualMatch<int>(
[](int i) {
std::cout << "INT MATCHED - "
<< i << std::endl;
}
),
SF::virtualMatch<char>(
[](char i) {
std::cout << "CHAR MATCHED - "
<< i << std::endl;
}
)
);
auto p1 = SF::vpack<int>(40);
auto p2 = SF::vpack<char>('7');
auto p3 = SF::vpack<long>(7);
(*vmf)(p1);
(*vmf)(p2);
(*vmf)(p3);
// prints out:
// INT MATCHED - 40
// CHAR MATCHED - 7
// throws...
virtual void templatious::VirtualMatchFunctor::operator() ( const VirtualPack p)
inlinevirtual

Match VirtualPack. Throws an exception if pack couldn't be matched.

Parameters
[in]pVirtual pack to match.

Example:

auto vmf = SF::virtualMatchFunctorPtr(
SF::virtualMatch<int>(
[](int i) {
std::cout << "INT MATCHED - "
<< i << std::endl;
}
),
SF::virtualMatch<char>(
[](char i) {
std::cout << "CHAR MATCHED - "
<< i << std::endl;
}
)
);
auto p1 = SF::vpack<int>(40);
auto p2 = SF::vpack<char>('7');
auto p3 = SF::vpack<long>(7);
(*vmf)(p1);
(*vmf)(p2);
(*vmf)(p3);
// prints out:
// INT MATCHED - 40
// CHAR MATCHED - 7
// throws...
virtual void templatious::VirtualMatchFunctor::operator() ( VirtualPack p) const
inlinevirtual

Match VirtualPack. Throws an exception if pack couldn't be matched.

Parameters
[in]pVirtual pack to match.

Example:

auto vmf = SF::virtualMatchFunctorPtr(
SF::virtualMatch<int>(
[](int i) {
std::cout << "INT MATCHED - "
<< i << std::endl;
}
),
SF::virtualMatch<char>(
[](char i) {
std::cout << "CHAR MATCHED - "
<< i << std::endl;
}
)
);
auto p1 = SF::vpack<int>(40);
auto p2 = SF::vpack<char>('7');
auto p3 = SF::vpack<long>(7);
(*vmf)(p1);
(*vmf)(p2);
(*vmf)(p3);
// prints out:
// INT MATCHED - 40
// CHAR MATCHED - 7
// throws...
virtual void templatious::VirtualMatchFunctor::operator() ( const VirtualPack p) const
inlinevirtual

Match VirtualPack. Throws an exception if pack couldn't be matched.

Parameters
[in]pVirtual pack to match.

Example:

auto vmf = SF::virtualMatchFunctorPtr(
SF::virtualMatch<int>(
[](int i) {
std::cout << "INT MATCHED - "
<< i << std::endl;
}
),
SF::virtualMatch<char>(
[](char i) {
std::cout << "CHAR MATCHED - "
<< i << std::endl;
}
)
);
auto p1 = SF::vpack<int>(40);
auto p2 = SF::vpack<char>('7');
auto p3 = SF::vpack<long>(7);
(*vmf)(p1);
(*vmf)(p2);
(*vmf)(p3);
// prints out:
// INT MATCHED - 40
// CHAR MATCHED - 7
// throws...
virtual bool templatious::VirtualMatchFunctor::tryMatch ( VirtualPack p)
pure virtual

Try to match VirtualPack. Returns true if matched, false otherwise.

Parameters
[in]pVirtual pack to match.

Example:

auto vmf = SF::virtualMatchFunctorPtr(
SF::virtualMatch<int>(
[](int i) {
std::cout << "INT MATCHED - "
<< i << std::endl;
}
),
SF::virtualMatch<char>(
[](char i) {
std::cout << "CHAR MATCHED - "
<< i << std::endl;
}
)
);
auto p1 = SF::vpack<int>(40);
auto p2 = SF::vpack<char>('7');
auto p3 = SF::vpack<long>(7);
bool aMatch = vmf->tryMatch(p1);
bool bMatch = vmf->tryMatch(p2);
bool cMatch = vmf->tryMatch(p3);
// prints out:
// INT MATCHED - 40
// CHAR MATCHED - 7
assert( aMatch);
assert( bMatch);
assert(!cMatch);

Implemented in templatious::VirtualMatchFunctorVImpl< StoragePolicy, Args >, and templatious::DynamicVMatchFunctor.

virtual bool templatious::VirtualMatchFunctor::tryMatch ( const VirtualPack p)
pure virtual

Try to match VirtualPack. Returns true if matched, false otherwise.

Parameters
[in]pVirtual pack to match.

Example:

auto vmf = SF::virtualMatchFunctorPtr(
SF::virtualMatch<int>(
[](int i) {
std::cout << "INT MATCHED - "
<< i << std::endl;
}
),
SF::virtualMatch<char>(
[](char i) {
std::cout << "CHAR MATCHED - "
<< i << std::endl;
}
)
);
auto p1 = SF::vpack<int>(40);
auto p2 = SF::vpack<char>('7');
auto p3 = SF::vpack<long>(7);
bool aMatch = vmf->tryMatch(p1);
bool bMatch = vmf->tryMatch(p2);
bool cMatch = vmf->tryMatch(p3);
// prints out:
// INT MATCHED - 40
// CHAR MATCHED - 7
assert( aMatch);
assert( bMatch);
assert(!cMatch);

Implemented in templatious::VirtualMatchFunctorVImpl< StoragePolicy, Args >, and templatious::DynamicVMatchFunctor.

virtual bool templatious::VirtualMatchFunctor::tryMatch ( VirtualPack p) const
pure virtual

Try to match VirtualPack. Returns true if matched, false otherwise.

Parameters
[in]pVirtual pack to match.

Example:

auto vmf = SF::virtualMatchFunctorPtr(
SF::virtualMatch<int>(
[](int i) {
std::cout << "INT MATCHED - "
<< i << std::endl;
}
),
SF::virtualMatch<char>(
[](char i) {
std::cout << "CHAR MATCHED - "
<< i << std::endl;
}
)
);
auto p1 = SF::vpack<int>(40);
auto p2 = SF::vpack<char>('7');
auto p3 = SF::vpack<long>(7);
bool aMatch = vmf->tryMatch(p1);
bool bMatch = vmf->tryMatch(p2);
bool cMatch = vmf->tryMatch(p3);
// prints out:
// INT MATCHED - 40
// CHAR MATCHED - 7
assert( aMatch);
assert( bMatch);
assert(!cMatch);

Implemented in templatious::VirtualMatchFunctorVImpl< StoragePolicy, Args >, and templatious::DynamicVMatchFunctor.

virtual bool templatious::VirtualMatchFunctor::tryMatch ( const VirtualPack p) const
pure virtual

Try to match VirtualPack. Returns true if matched, false otherwise.

Parameters
[in]pVirtual pack to match.

Example:

auto vmf = SF::virtualMatchFunctorPtr(
SF::virtualMatch<int>(
[](int i) {
std::cout << "INT MATCHED - "
<< i << std::endl;
}
),
SF::virtualMatch<char>(
[](char i) {
std::cout << "CHAR MATCHED - "
<< i << std::endl;
}
)
);
auto p1 = SF::vpack<int>(40);
auto p2 = SF::vpack<char>('7');
auto p3 = SF::vpack<long>(7);
bool aMatch = vmf->tryMatch(p1);
bool bMatch = vmf->tryMatch(p2);
bool cMatch = vmf->tryMatch(p3);
// prints out:
// INT MATCHED - 40
// CHAR MATCHED - 7
assert( aMatch);
assert( bMatch);
assert(!cMatch);

Implemented in templatious::VirtualMatchFunctorVImpl< StoragePolicy, Args >, and templatious::DynamicVMatchFunctor.


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