Equalizer 1.0

fabric/observer.h

00001 
00002 /* Copyright (c) 2009-2010, Stefan Eilemann <eile@equalizergraphics.com> 
00003  *
00004  * This library is free software; you can redistribute it and/or modify it under
00005  * the terms of the GNU Lesser General Public License version 2.1 as published
00006  * by the Free Software Foundation.
00007  *  
00008  * This library is distributed in the hope that it will be useful, but WITHOUT
00009  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00010  * FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more
00011  * details.
00012  * 
00013  * You should have received a copy of the GNU Lesser General Public License
00014  * along with this library; if not, write to the Free Software Foundation, Inc.,
00015  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
00016  */
00017 
00018 #ifndef EQFABRIC_OBSERVER_H
00019 #define EQFABRIC_OBSERVER_H
00020 
00021 #include <eq/fabric/api.h>
00022 #include <eq/fabric/object.h>         // base class
00023 #include <eq/fabric/types.h>
00024 #include <eq/fabric/visitorResult.h> // enum
00025 
00026 #include <string>
00027 #include <vector>
00028 
00029 namespace eq
00030 {
00031 namespace fabric
00032 {
00034     template< class C, class O > class Observer : public Object
00035     {
00036     public:
00038         typedef LeafVisitor< O > Visitor;
00039 
00043         const C* getConfig() const { return _config; }
00044 
00046         C* getConfig() { return _config; }
00047 
00049         ObserverPath getPath() const;
00050 
00052         EQFABRIC_INL void setEyeBase( const float eyeBase );
00053 
00055         float getEyeBase() const { return _data.eyeBase; }
00056 
00069         EQFABRIC_INL void setHeadMatrix( const Matrix4f& matrix );
00070 
00072         const Matrix4f& getHeadMatrix() const { return _data.headMatrix; }
00074 
00084         EQFABRIC_INL VisitorResult accept( Visitor& visitor );
00085 
00087         EQFABRIC_INL VisitorResult accept( Visitor& visitor ) const;
00088 
00089         virtual void backup(); 
00090         virtual void restore(); 
00091 
00092         
00093     protected:
00095         EQFABRIC_INL Observer( C* config );
00096 
00098         EQFABRIC_INL virtual ~Observer();
00099 
00101         virtual void serialize( co::DataOStream& os,
00102                                 const uint64_t dirtyBits );
00104         virtual void deserialize( co::DataIStream& is,
00105                                   const uint64_t dirtyBits );
00106         virtual void setDirty( const uint64_t bits ); 
00107 
00109         enum DirtyBits
00110         {
00111             DIRTY_EYE_BASE   = Object::DIRTY_CUSTOM << 0,
00112             DIRTY_HEAD       = Object::DIRTY_CUSTOM << 1,
00113             DIRTY_OBSERVER_BITS =
00114                 DIRTY_EYE_BASE | DIRTY_HEAD | DIRTY_OBJECT_BITS
00115         };
00116 
00118         virtual uint64_t getRedistributableBits() const
00119             { return DIRTY_OBSERVER_BITS; }
00120 
00121     private:
00123         C* const _config;
00124 
00125         struct BackupData
00126         {
00127             BackupData() : eyeBase( .05f ), headMatrix( Matrix4f::IDENTITY ) {}
00128 
00130             float eyeBase;
00131 
00133             Matrix4f headMatrix;
00134         }
00135             _data, _backup;
00136 
00137         struct Private;
00138         Private* _private; // placeholder for binary-compatible changes
00139     };
00140 
00141     template< class C, class O >
00142     EQFABRIC_INL std::ostream& operator << ( std::ostream&,
00143                                              const Observer< C, O >& );
00144 }
00145 }
00146 #endif // EQFABRIC_OBSERVER_H
Generated on Sun May 8 2011 19:11:07 for Equalizer 1.0 by  doxygen 1.7.3