vee_ptr.h

Go to the documentation of this file.
00001 /* -*- C++ -*- */
00002 
00003 /* COPYRIGHT
00004  *
00005  * This file is part of the Visual Effects Engine - VEE
00006  *
00007  * Read the "VEE-LICENSE" file for the license.
00008  *
00009  * Authors & Copyright:   
00010  *
00011  * Tommi Ilmonen, Tuukka Heikura, Marko Myllymaa and 
00012  * Janne Kontkanen 2001-2004
00013  *
00014  * Additional copyrights: Tekes 2003-2004
00015  *
00016  * firstname.lastname@hut.fi
00017  *
00018  */
00019 
00020 #ifndef VEE_PTR_H
00021 #define VEE_PTR_H
00022 
00023 class VEE_Ptr
00024 {
00025 public:
00026 
00027   static inline int distance(const void *p1, const void *p2)
00028   { 
00029     const char * c1 = (const char *) p1;
00030     const char * c2 = (const char *) p2;
00031     
00032     return c1 - c2;
00033   }
00034 
00035   template <class T>
00036   static inline T * offset(T *p, int offsetBytes)
00037   { return (T *) (((char *) p) + offsetBytes); }
00038 
00039   template <class T>
00040   static inline const T * offset(const T *p, int offsetBytes)
00041   { return (T *) (((char *) p) + offsetBytes); }
00042 
00043   // static inline const void * offset(const void *p, int offsetBytes)
00044   // { return ((char *) p) + offsetBytes; }
00045 
00047   static inline float ptrToRandom(void * ptr)
00048   {
00049     unsigned seed = (int) ptr;
00050     seed = seed * 134695621 + 1;
00051     seed = seed * 134695621 + 1;
00052     seed = seed * 134695621 + 1;
00053 
00054     return seed * (1.0 / (float) ((unsigned) 0xffffffff));
00055   }
00056 
00057 };
00058 
00059 #endif

Generated on Mon Mar 12 21:09:01 2007 for VEE - The Visual Effects Engine by  doxygen 1.4.6