framerateEqualizer.h

00001 
00002 /* Copyright (c) 2008-2009, 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 EQS_FRAMERATEEQUALIZER_H
00019 #define EQS_FRAMERATEEQUALIZER_H
00020 
00021 #include "../channelListener.h" // base class
00022 #include "equalizer.h"          // base class
00023 
00024 #include <deque>
00025 #include <map>
00026 
00027 namespace eq
00028 {
00029 namespace server
00030 {
00031     class FramerateEqualizer;
00032     std::ostream& operator << ( std::ostream& os, const FramerateEqualizer* );
00033 
00040     class FramerateEqualizer : public Equalizer
00041     {
00042     public:
00043         EQSERVER_EXPORT FramerateEqualizer();
00044         FramerateEqualizer( const FramerateEqualizer& from );
00045         virtual ~FramerateEqualizer();
00046         virtual Equalizer* clone() const
00047             { return new FramerateEqualizer( *this ); }
00048         virtual void toStream( std::ostream& os ) const { os << this; }
00049 
00051         virtual void attach( Compound* compound );
00052 
00054         virtual void notifyUpdatePre( Compound* compound, 
00055                                       const uint32_t frameNumber );
00056 
00057     protected:
00058         virtual void notifyChildAdded( Compound* compound, Compound* child )
00059             { EQASSERT( _nSamples == 0 ); }
00060         virtual void notifyChildRemove( Compound* compound, Compound* child )
00061             { EQASSERT( _nSamples == 0 ); }
00062         
00063     private:
00065         typedef std::pair< uint32_t, float > FrameTime;
00066         
00068         std::deque< FrameTime > _times;
00069 
00071         class LoadListener : public ChannelListener
00072         {
00073         public:
00075             virtual void notifyLoadData( Channel* channel, 
00076                                          const uint32_t frameNumber,
00077                                          const uint32_t nStatistics,
00078                                          const eq::Statistic* statistics  );
00079 
00080             FramerateEqualizer* parent;
00081             uint32_t period;
00082         };
00083 
00085         std::vector< LoadListener > _loadListeners;
00086         friend class LoadListener;
00087 
00089         uint32_t _nSamples;
00090 
00091         void _init();
00092         void _exit();
00093     };
00094 }
00095 }
00096 
00097 #endif // EQS_LOADBALANCER_H
Generated on Mon Aug 10 18:58:33 2009 for Equalizer 0.9 by  doxygen 1.5.8