1////////////////////////////////////////////////////////////////////////////////
2// //
3// This software is supplied under the terms of a license agreement or //
4// nondisclosure agreement with Mitov Software and may not be copied //
5// or disclosed except in accordance with the terms of that agreement. //
6// Copyright(c) 2002-2016 Mitov Software. All Rights Reserved. //
7// //
8////////////////////////////////////////////////////////////////////////////////
9
10#ifndef _MITOV_REMEMBER_h
11#define _MITOV_REMEMBER_h
12
13#include <Mitov.h>
14
15namespace Mitov
16{
17//---------------------------------------------------------------------------
18 template<typename T_STORE, typename T_DATA> class Remember : public CommonEnableFilter
19 {
20 typedef CommonFilter inherited;
21
22 public:
23 OpenWire::SinkPin RememberInputPin;
24 OpenWire::SinkPin RecallInputPin;
25
26 protected:
27 T_STORE FInData;
28 T_STORE FSavedData;
29
30 protected:
31 virtual void DoReceive( void *_Data ) override
32 {
33 FInData = *(T_DATA*)_Data;
34 }
35
36 protected:
37 void DoReceiveRemember( void *_Data )
38 {
39 if( Enabled )
40 FSavedData = FInData;
41 }
42
43 void DoRecallSnapshot( void *_Data )
44 {
45 if( Enabled )
46 OutputPin.SendValue( FSavedData );
47 }
48
49 public:
50 Remember( T_STORE AData ) :
51 FInData( AData ),
52 FSavedData( AData )
53 {
54 RememberInputPin.SetCallback( this, (OpenWire::TOnPinReceive)&Remember::DoReceiveRemember );
55 RecallInputPin.SetCallback( this, (OpenWire::TOnPinReceive)&Remember::DoRecallSnapshot );
56 }
57 };
58//---------------------------------------------------------------------------
59}
60
61#endif