00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #include "sampa/core/gated.h"
00020 #include "sampa/core/persistence.cxx"
00021 #include <cstring>
00022
00023 namespace Sampa {
00024
00025 template<class UserType>
00026 Gated<UserType>::Gated(const ContainerName& nm, const UserType& default_value)
00027 : GatedBase(nm)
00028 {
00029 std::memset(m_value, 0, sizeof(UserType[2]));
00030 m_value[0] = default_value;
00031 m_value[1] = default_value;
00032 }
00033
00034 template<class UserType>
00035 void Gated<UserType>::schedule(const UserType& v)
00036 {
00037 m_value[1-m_curr] = v;
00038 request_update();
00039 }
00040
00041 template<class UserType>
00042 void Gated<UserType>::force(const UserType& v)
00043 {
00044 m_value[m_curr] = v;
00045 }
00046
00047 }
00048
00049 #define SAMPA_MAKE_GATED(UserType) \
00050 namespace Sampa { \
00051 SAMPA_MAKE_TMPL_PERSISTENT(Gated<UserType>, Gated, NO_REFS); \
00052 template class Gated<UserType>; \
00053 }
00054