42 lines
809 B
C++
42 lines
809 B
C++
/*
|
||
* StatusTemplate.hpp
|
||
*
|
||
* Created on: 29 сент. 2019 г.
|
||
* Author: user
|
||
*/
|
||
|
||
#ifndef SOURCE_SCHEMATIC_STATUSTEMPLATE_HPP_
|
||
#define SOURCE_SCHEMATIC_STATUSTEMPLATE_HPP_
|
||
|
||
#include "../systemic/IStatus.hh"
|
||
|
||
#if __cplusplus >= 201103L
|
||
#include <functional>
|
||
#endif
|
||
|
||
namespace systemic { namespace detail {
|
||
|
||
template<typename Function>
|
||
class TemplateStatus : public IStatus {
|
||
Function & function;
|
||
public:
|
||
TemplateStatus(Function & f) : function(f) {}
|
||
|
||
operator bool() const { return function(); }
|
||
};
|
||
|
||
|
||
#if __cplusplus >= 201103L
|
||
class FunctionalStatus : public systemic::IStatus {
|
||
std::function<bool()> f;
|
||
public:
|
||
FunctionalStatus( std::function<bool()> _f) : f(_f) {}
|
||
operator bool() const { return f(); }
|
||
};
|
||
|
||
#endif
|
||
|
||
}}
|
||
|
||
#endif /* SOURCE_SCHEMATIC_STATUSTEMPLATE_HPP_ */
|