Introduction Manual Class Reference Header Reference

zoidcom_replicator_bool.h

Go to the documentation of this file.
00001 /****************************************
00002 * zoidcom_replicator_bool.h
00003 * boolean value replicator
00004 *
00005 * This file is part of the "Zoidcom Automated Networking System" application library.
00006 * Copyright (C)2002-2007 by Joerg Rueppel. See documentation for copyright and licensing details.
00007 *****************************************/
00008 
00009 #ifndef _ZOIDREPLICATORBOOL_H_
00010 #define _ZOIDREPLICATORBOOL_H_
00011 
00015 #include "zoidcom.h"
00016 
00019 class ZCOM_API ZCom_Replicate_Boolp : public ZCom_ReplicatorBasic
00020 {
00021 private:
00022   bool*     m_ptr;
00023   bool      m_cmp;
00024 public:
00026   ZCom_Replicate_Boolp(bool *_data, ZCom_ReplicatorSetup *_setup) : ZCom_ReplicatorBasic(_setup) { m_ptr = _data; m_flags |= ZCOM_REPLICATOR_INITIALIZED; }
00028   ZCom_Replicate_Boolp(bool *_data, zU8 _flags, zU8 _rules, zU8 _intercept_id = 0, zS16 _mindelay = -1, zS16 _maxdelay = -1);
00029   bool checkState(){bool s = (m_cmp != *m_ptr); m_cmp = *m_ptr; return s;}
00030   void packData(ZCom_BitStream *_stream) { _stream->addBool(*m_ptr);}
00031   void unpackData(ZCom_BitStream *_stream, bool _store, zU32 _estimated_time_sent) { if (_store) *m_ptr = _stream->getBool(); else _stream->getBool();}
00032   void Process(eZCom_NodeRole _localrole, zU32 _simulation_time_passed) {};
00033   void* peekData() { assert(getPeekStream()); return (void*) getPeekStream()->getBool(); }
00034   void clearPeekData() {};
00035 };
00036 
00037 /*
00038  *  (bool) Replicator -----------------------------------------------------------
00039 */
00040 
00043 class ZCOM_API ZCom_Replicate_Bool : public ZCom_ReplicatorBasic
00044 {
00045 private:
00046   bool      m_data;
00047   bool      m_cmp;
00048 public:
00050   ZCom_Replicate_Bool(bool _data, ZCom_ReplicatorSetup *_setup) : ZCom_ReplicatorBasic(_setup) {m_data = _data; m_flags |= ZCOM_REPLICATOR_INITIALIZED; }
00052   ZCom_Replicate_Bool(bool _data, zU8 _flags, zU8 _rules, zU8 _intercept_id = 0, zS16 _mindelay = -1, zS16 _maxdelay = -1);
00053   bool checkState(){bool s = (m_cmp != m_data); m_cmp = m_data; return s;}
00054   void packData(ZCom_BitStream *_stream) { _stream->addBool(m_data);}
00055   void unpackData(ZCom_BitStream *_stream, bool _store, zU32 _estimated_time_sent) { if (_store) m_data = _stream->getBool(); else _stream->getBool();}
00056   void Process(eZCom_NodeRole _localrole, zU32 _simulation_time_passed) {};
00057   void* peekData() { assert(getPeekStream()); return (void*) getPeekStream()->getBool(); }
00058   void clearPeekData() {};
00059 
00061   operator bool() { return m_data; }
00063   bool& operator=(bool _data) {m_data = _data; return m_data;}
00065   bool getValue() { return m_data; }
00067   void setValue(bool _val) { m_data = _val; }
00068 };
00069 
00070 #endif

This file is part of the documentation for Zoidcom. Documentation copyright © 2004-2008 by Jörg Rüppel. Generated on Sat Aug 16 15:26:49 2008 for Zoidcom by doxygen 1.4.6-NO