Equalizer  1.4.1
range.h
00001 
00002 /* Copyright (c) 2006-2012, 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_RANGE_H
00019 #define EQFABRIC_RANGE_H
00020 
00021 #include <eq/fabric/api.h>
00022 
00023 #include <iostream>
00024 
00025 namespace eq
00026 {
00027 namespace fabric
00028 {
00030     class Range 
00031     {
00032     public:
00036         Range() : start(0.f), end(1.f)  {}
00037 
00039         Range( const float start_, const float end_ )
00040                 : start(start_), end(end_) {}
00042 
00046         bool operator == ( const Range& rhs ) const
00047             { return start==rhs.start && end==rhs.end; }
00048         
00050         bool operator != ( const Range& rhs ) const
00051             { return start!=rhs.start || end!=rhs.end; }
00052         
00054         float getSize() const { return end - start; }
00055 
00057         void invalidate() { start=0.f; end=0.f; }
00058 
00060         bool isValid() const 
00061             { return ( start>=0.f && end <=1.f && (end - start) >= 0.f ); }
00062 
00064         bool hasData() const { return  (end - start) > 0.f; }
00065 
00067         void apply( const Range& rhs )
00068             {
00069                 const float w = end-start;
00070                 end    = start + rhs.end * w;
00071                 start += rhs.start * w;
00072             }
00073         
00074 
00075         float start; 
00076         float end;   
00077 
00078         EQFABRIC_API static const Range ALL; 
00079     };
00080 
00081     inline std::ostream& operator << ( std::ostream& os, const Range& range )
00082     {
00083         os << "range    [ " << range.start << " " << range.end << " ]";
00084         return os;
00085     }
00086 }
00087 }
00088 #endif // EQFABRIC_RANGE_H
Generated on Mon Nov 26 2012 14:41:49 for Equalizer 1.4.1 by  doxygen 1.7.6.1