Equalizer
1.2.1
|
00001 00002 /* Copyright (c) 2009-2011, 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/focusMode.h> // enum 00023 #include <eq/fabric/object.h> // base class 00024 #include <eq/fabric/types.h> 00025 #include <eq/fabric/visitorResult.h> // enum 00026 00027 #include <string> 00028 #include <vector> 00029 00030 namespace eq 00031 { 00032 namespace fabric 00033 { 00035 template< class C, class O > class Observer : public Object 00036 { 00037 public: 00039 typedef LeafVisitor< O > Visitor; 00040 00044 const C* getConfig() const { return _config; } 00045 00047 C* getConfig() { return _config; } 00048 00050 ObserverPath getPath() const; 00051 00053 EQFABRIC_INL void setEyeBase( const float eyeBase ); 00054 00056 float getEyeBase() const { return _data.eyeBase; } 00057 00059 EQFABRIC_INL void setFocusDistance( const float focusDistance ); 00060 00062 float getFocusDistance() const { return _data.focusDistance; } 00063 00065 EQFABRIC_INL void setFocusMode( const FocusMode focusMode ); 00066 00068 FocusMode getFocusMode() const { return _data.focusMode; } 00069 00082 EQFABRIC_INL void setHeadMatrix( const Matrix4f& matrix ); 00083 00085 const Matrix4f& getHeadMatrix() const { return _data.headMatrix; } 00087 00097 EQFABRIC_INL VisitorResult accept( Visitor& visitor ); 00098 00100 EQFABRIC_INL VisitorResult accept( Visitor& visitor ) const; 00101 00102 virtual void backup(); 00103 virtual void restore(); 00104 00105 00106 protected: 00108 EQFABRIC_INL Observer( C* config ); 00109 00111 EQFABRIC_INL virtual ~Observer(); 00112 00114 virtual void serialize( co::DataOStream& os, 00115 const uint64_t dirtyBits ); 00117 virtual void deserialize( co::DataIStream& is, 00118 const uint64_t dirtyBits ); 00119 virtual void setDirty( const uint64_t bits ); 00120 00122 enum DirtyBits 00123 { 00124 DIRTY_EYE_BASE = Object::DIRTY_CUSTOM << 0, 00125 DIRTY_HEAD = Object::DIRTY_CUSTOM << 1, 00126 DIRTY_FOCUS = Object::DIRTY_CUSTOM << 2, 00127 DIRTY_OBSERVER_BITS = 00128 DIRTY_EYE_BASE | DIRTY_HEAD | DIRTY_FOCUS | DIRTY_OBJECT_BITS 00129 }; 00130 00132 virtual uint64_t getRedistributableBits() const 00133 { return DIRTY_OBSERVER_BITS; } 00134 00135 private: 00137 C* const _config; 00138 00139 struct BackupData 00140 { 00141 BackupData(); 00142 00144 float eyeBase; 00145 00147 float focusDistance; 00148 00150 FocusMode focusMode; 00151 00153 Matrix4f headMatrix; 00154 } 00155 _data, _backup; 00156 00157 struct Private; 00158 Private* _private; // placeholder for binary-compatible changes 00159 }; 00160 00161 template< class C, class O > 00162 EQFABRIC_INL std::ostream& operator << ( std::ostream&, 00163 const Observer< C, O >& ); 00164 } 00165 } 00166 #endif // EQFABRIC_OBSERVER_H