Equalizer  1.2.1
uuid.h
00001 
00002 /* Copyright (c) 2006-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 COBASE_UUID_H
00019 #define COBASE_UUID_H
00020 
00021 #include <co/base/rng.h>     // used in inline method
00022 #include <co/base/uint128_t.h> // base class
00023 
00024 namespace co
00025 {
00026 namespace base
00027 {
00028 
00034     class UUID : public uint128_t
00035     {
00036     public:
00044         explicit UUID( const bool generate = false ) : uint128_t()
00045             { 
00046                 while( generate && high() == 0 )
00047                 {         
00048                     RNG rng;
00049                     high() = rng.get< uint64_t >();
00050                     low() = rng.get< uint64_t >();
00051                 }
00052             }
00053 
00058         UUID( const uint64_t high_, const uint64_t low_ ) 
00059             : uint128_t( high_, low_ ) {}
00060 
00066         UUID( const uint128_t& from ) : uint128_t( from ) {}
00067 
00069         UUID& operator = ( const std::string& from )
00070             { *(static_cast< uint128_t* >( this )) = from; return *this; }
00071 
00073         bool isGenerated() const { return high() != 0; }
00074     };
00075 }
00076 }
00077 
00078 #endif // COBASE_UUID_H
Generated on Fri Jun 8 2012 15:44:32 for Equalizer 1.2.1 by  doxygen 1.8.0