gated.cxx

Go to the documentation of this file.
00001 //    sampalib.org ESL library and tools
00002 //    Copyright (C) 2007  Thierry Grellier
00003 //
00004 //    This program is free software; you can redistribute it and/or modify
00005 //    it under the terms of the GNU General Public License version 2 as
00006 //    published by the Free Software Foundation.
00007 //
00008 //    This program is distributed in the hope that it will be useful,
00009 //    but WITHOUT ANY WARRANTY; without even the implied warranty of
00010 //    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00011 //    GNU General Public License for more details.
00012 //
00013 //    You should have received a copy of the GNU General Public License along
00014 //    with this program; if not, write to the Free Software Foundation, Inc.,
00015 //    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
00016 //
00017 //    contact: www.sampalib.org
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 } // namespace Sampa
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 

Generated on Sat Feb 16 16:23:15 2008 for Sampa by  doxygen 1.5.3