Main Page   Groups   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Concepts

itkByteSwapper.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Insight Segmentation & Registration Toolkit
00004   Module:    $RCSfile: itkByteSwapper.h,v $
00005   Language:  C++
00006   Date:      $Date: 2006-03-18 18:06:25 $
00007   Version:   $Revision: 1.15 $
00008 
00009   Copyright (c) Insight Software Consortium. All rights reserved.
00010   See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
00011 
00012   Portions of this code are covered under the VTK copyright.
00013   See VTKCopyright.txt or http://www.kitware.com/VTKCopyright.htm for details.
00014 
00015      This software is distributed WITHOUT ANY WARRANTY; without even 
00016      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
00017      PURPOSE.  See the above copyright notices for more information.
00018 
00019 =========================================================================*/
00020 #ifndef __itkByteSwapper_h
00021 #define __itkByteSwapper_h
00022 
00023 #include "itkObject.h"
00024 #include "itkObjectFactory.h"
00025 
00026 namespace itk
00027 {
00028 
00040 template <class T>
00041 class ITK_EXPORT ByteSwapper : public Object
00042 {
00043 public:
00045   typedef ByteSwapper               Self;
00046   typedef Object                    Superclass;
00047   typedef SmartPointer<Self>        Pointer;
00048   typedef SmartPointer<const Self>  ConstPointer;
00049 
00051   typedef std::ostream OStreamType;
00052 
00054   itkTypeMacro(ByteSwapper,Object);
00055 
00057   static bool SystemIsBigEndian ();
00058   static bool SystemIsBE () { return SystemIsBigEndian(); }
00059   static bool SystemIsLittleEndian ();
00060   static bool SystemIsLE () { return SystemIsLittleEndian(); }
00062 
00068   static void SwapFromSystemToBigEndian(T *p);
00069 
00075   static void SwapRangeFromSystemToBigEndian(T *p, unsigned long num);
00076 
00084   static void SwapWriteRangeFromSystemToBigEndian(T *p, int num, 
00085                                                   OStreamType *fp);
00087 
00093   static void SwapFromSystemToLittleEndian(T *p);
00094 
00100   static void SwapRangeFromSystemToLittleEndian(T *p, unsigned long num);
00101 
00109   static void SwapWriteRangeFromSystemToLittleEndian(T *p, int num, 
00110                                                      OStreamType *fp);
00112 
00113 protected:
00114   ByteSwapper() {}
00115   ~ByteSwapper() {}
00116 
00118   static void Swap2(void *p);
00119 
00122   static void Swap2Range(void *p, unsigned long num);
00123 
00126   static void SwapWrite2Range(void *p, unsigned long num, OStreamType *fp);
00127 
00129   static void Swap4(void *p);
00130 
00133   static void Swap4Range(void *p, unsigned long num);
00134 
00137   static void SwapWrite4Range(void *p, unsigned long num, OStreamType *fp);
00138 
00140   static void Swap8(void *p);
00141 
00144   static void Swap8Range(void *p, unsigned long num);
00145 
00148   static void SwapWrite8Range(void *p, unsigned long num, OStreamType *fp);
00149 
00150 private:
00151   ByteSwapper(const ByteSwapper&); //purposely not implemented
00152   void operator=(const ByteSwapper&); //purposely not implemented
00153   
00154 };
00155 
00156 } // end namespace itk
00157   
00158 #ifndef ITK_MANUAL_INSTANTIATION
00159 #include "itkByteSwapper.txx"
00160 #endif
00161 
00162 #endif
00163 

Generated at Mon Apr 14 11:53:29 2008 for ITK by doxygen 1.5.1 written by Dimitri van Heesch, © 1997-2000