libraries / Mitov / Mitov_Snapshot.hon commit Added link to project report (97a3ba0)
   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_SNAPSHOT_h
  11#define _MITOV_SNAPSHOT_h
  12
  13#include <Mitov.h>
  14
  15namespace Mitov
  16{
  17//---------------------------------------------------------------------------
  18        template<typename T_STORE, typename T_DATA> class Snapshot : public CommonEnableFilter
  19        {
  20                typedef CommonFilter inherited;
  21
  22        public:
  23                OpenWire::SinkPin       SnapshotInputPin;
  24
  25        protected:
  26                T_STORE FData;
  27
  28        protected:
  29                virtual void DoReceive( void *_Data ) override
  30                {
  31                        FData = *(T_DATA*)_Data;
  32                }
  33
  34        protected:
  35                void TakeSnapshot()
  36                {
  37                        OutputPin.SendValue( FData );
  38                }
  39
  40        protected:
  41                void DoReceiveSnapshot( void *_Data )
  42                {
  43                        if( Enabled )
  44                                TakeSnapshot();
  45                }
  46
  47        public:
  48                Snapshot( T_STORE AData ) : 
  49                        FData( AData )
  50                {
  51                        SnapshotInputPin.SetCallback( this, (OpenWire::TOnPinReceive)&Snapshot::DoReceiveSnapshot );
  52                }
  53        };
  54//---------------------------------------------------------------------------
  55}
  56
  57#endif