Equalizer  1.2.1
range.h
00001 
00002 /* Copyright (c) 2006-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_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         void invalidate() { start=0.f; end=0.f; }
00055 
00057         bool isValid() const 
00058             { return ( start>=0.f && end <=1.f && (end - start) >= 0.f ); }
00059 
00061         bool hasData() const { return  (end - start) > 0.f; }
00062 
00064         void apply( const Range& rhs )
00065             {
00066                 const float w = end-start;
00067                 end    = start + rhs.end * w;
00068                 start += rhs.start * w;
00069             }
00070         
00071 
00072         float start; 
00073         float end;   
00074 
00075         EQFABRIC_API static const Range ALL; 
00076     };
00077 
00078     inline std::ostream& operator << ( std::ostream& os, const Range& range )
00079     {
00080         os << "range    [ " << range.start << " " << range.end << " ]";
00081         return os;
00082     }
00083 }
00084 }
00085 #endif // EQFABRIC_RANGE_H
Generated on Fri Jun 8 2012 15:44:32 for Equalizer 1.2.1 by  doxygen 1.8.0