56 lines
1.3 KiB
C++
56 lines
1.3 KiB
C++
/*
|
||
* ControlSystemEnable.hpp
|
||
*
|
||
* Created on: 1 февр. 2021 г.
|
||
* Author: titov
|
||
*/
|
||
|
||
#ifndef UMLIBRARY_TECHNOLOGICAL_ADAPTER_CONTROLSYSTEMENABLE_HPP_
|
||
#define UMLIBRARY_TECHNOLOGICAL_ADAPTER_CONTROLSYSTEMENABLE_HPP_
|
||
|
||
#include "ControlSystemWrapper.hpp"
|
||
#include "../../systemic/IStatus.hh"
|
||
|
||
namespace technological { namespace adapter {
|
||
|
||
template<class Input>
|
||
class ControlSystemEnable : public TieInterface<Input> {
|
||
public:
|
||
ControlSystemEnable( TieInterface<Input> & tie, systemic::IStatus & enable );
|
||
|
||
Input * try_connect();
|
||
void disconnect();
|
||
|
||
private:
|
||
TieInterface<Input> & tie;
|
||
systemic::IStatus & enable;
|
||
bool connect;
|
||
};
|
||
|
||
}
|
||
}
|
||
|
||
template<class Input>
|
||
inline technological::adapter::ControlSystemEnable<Input>::ControlSystemEnable(
|
||
TieInterface<Input> & tie, systemic::IStatus & enable ) : tie(tie), enable(enable) {}
|
||
|
||
template<class Input>
|
||
inline Input * technological::adapter::ControlSystemEnable<Input>::try_connect() {
|
||
|
||
if( connect = enable )
|
||
return tie.try_connect();
|
||
else
|
||
return nullptr;
|
||
|
||
}
|
||
|
||
template<class Input>
|
||
inline void technological::adapter::ControlSystemEnable<Input>::disconnect() {
|
||
|
||
if( connect )
|
||
tie.disconnect();
|
||
|
||
}
|
||
|
||
#endif /* UMLIBRARY_TECHNOLOGICAL_ADAPTER_CONTROLSYSTEMENABLE_HPP_ */
|