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: 2009-12-08 19:53:43 $
00007   Version:   $Revision: 1.17 $
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 
00072   typedef  ::size_t      BufferSizeType;
00073 
00079   static void SwapRangeFromSystemToBigEndian(T *p, BufferSizeType num);
00080 
00088   static void SwapWriteRangeFromSystemToBigEndian(T *p, int num, 
00089                                                   OStreamType *fp);
00091 
00097   static void SwapFromSystemToLittleEndian(T *p);
00098 
00104   static void SwapRangeFromSystemToLittleEndian(T *p, BufferSizeType num);
00105 
00113   static void SwapWriteRangeFromSystemToLittleEndian(T *p, int num, 
00114                                                      OStreamType *fp);
00116 
00117 protected:
00118   ByteSwapper() {}
00119   ~ByteSwapper() {}
00120 
00122   static void Swap2(void *p);
00123 
00126   static void Swap2Range(void *p, BufferSizeType num);
00127 
00130   static void SwapWrite2Range(void *p, BufferSizeType num, OStreamType *fp);
00131 
00133   static void Swap4(void *p);
00134 
00137   static void Swap4Range(void *p, BufferSizeType num);
00138 
00141   static void SwapWrite4Range(void *p, BufferSizeType num, OStreamType *fp);
00142 
00144   static void Swap8(void *p);
00145 
00148   static void Swap8Range(void *p, BufferSizeType num);
00149 
00152   static void SwapWrite8Range(void *p, BufferSizeType num, OStreamType *fp);
00153 
00154 private:
00155   ByteSwapper(const ByteSwapper&); //purposely not implemented
00156   void operator=(const ByteSwapper&); //purposely not implemented
00157   
00158 };
00159 
00160 } // end namespace itk
00161   
00162 #ifndef ITK_MANUAL_INSTANTIATION
00163 #include "itkByteSwapper.txx"
00164 #endif
00165 
00166 #endif
00167 

Generated at Fri Apr 16 18:01:45 2010 for ITK by doxygen 1.6.1 written by Dimitri van Heesch, © 1997-2000