cmtkClassStream.h

Go to the documentation of this file.
00001 /*
00002 //
00003 //  Copyright 1997-2009 Torsten Rohlfing
00004 //
00005 //  Copyright 2004-2010 SRI International
00006 //
00007 //  This file is part of the Computational Morphometry Toolkit.
00008 //
00009 //  http://www.nitrc.org/projects/cmtk/
00010 //
00011 //  The Computational Morphometry Toolkit is free software: you can
00012 //  redistribute it and/or modify it under the terms of the GNU General Public
00013 //  License as published by the Free Software Foundation, either version 3 of
00014 //  the License, or (at your option) any later version.
00015 //
00016 //  The Computational Morphometry Toolkit is distributed in the hope that it
00017 //  will be useful, but WITHOUT ANY WARRANTY; without even the implied
00018 //  warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019 //  GNU General Public License for more details.
00020 //
00021 //  You should have received a copy of the GNU General Public License along
00022 //  with the Computational Morphometry Toolkit.  If not, see
00023 //  <http://www.gnu.org/licenses/>.
00024 //
00025 //  $Revision: 2752 $
00026 //
00027 //  $LastChangedDate: 2011-01-17 11:33:31 -0800 (Mon, 17 Jan 2011) $
00028 //
00029 //  $LastChangedBy: torstenrohlfing $
00030 //
00031 */
00032 
00033 #ifndef __cmtkClassStream_h_included_
00034 #define __cmtkClassStream_h_included_
00035 
00036 #include <cmtkconfig.h>
00037 
00038 #include <IO/cmtkTypedStream.h>
00039 #include <IO/cmtkStudy.h>
00040 
00041 #include <Base/cmtkAffineXform.h>
00042 #include <Base/cmtkWarpXform.h>
00043 #include <Base/cmtkSplineWarpXform.h>
00044 #include <Base/cmtkParametricPlane.h>
00045 #include <Base/cmtkLandmark.h>
00046 #include <Base/cmtkLandmarkList.h>
00047 
00048 namespace
00049 cmtk
00050 {
00051 
00054 
00059 class ClassStream : 
00061   public TypedStream 
00062 {
00063 public:
00065   typedef enum {
00067     READ = TYPEDSTREAM_READ,
00069     WRITE = TYPEDSTREAM_WRITE,
00071     WRITE_ZLIB = TYPEDSTREAM_WRITE_ZLIB,
00073     APPEND = TYPEDSTREAM_APPEND
00074   } FileMode;
00075 
00077   ClassStream() : TypedStream() {}
00078 
00083   ClassStream( const char *filename, const FileMode mode )
00084     : TypedStream( filename,  (TypedStreamMode) mode ) {}
00085 
00091   ClassStream( const char *dir, const char *archive, const FileMode mode )
00092     : TypedStream( dir, archive, (TypedStreamMode) mode ) {}
00093 
00096   void Open( const char *filename, const FileMode mode ) {
00097     this->TypedStream::Open( filename, (TypedStreamMode) mode );
00098   }
00099 
00102   void Open( const char *dir, const char *archive, const FileMode mode ) {
00103     this->TypedStream::Open( dir, archive, (TypedStreamMode) mode );
00104   }
00105 
00111   ClassStream& operator << ( const WarpXform *warpXform );
00112 
00117   ClassStream& operator << ( const SplineWarpXform& splineWarpXform )
00118   { return (*this) << &splineWarpXform; }
00119   
00121   ClassStream& operator >> ( WarpXform::SmartPtr& warpXform );
00122 
00124   ClassStream& operator >> ( WarpXform*& warpXform );
00125 
00127   ClassStream& Get ( WarpXform::SmartPtr& warpXform, const AffineXform* affineXform = NULL  );
00128 
00130   ClassStream& Get ( WarpXform*& warpXform, const AffineXform* affineXform = NULL  );
00131 
00132 private:
00134   ClassStream& PutWarp( const WarpXform* warpXform  );
00135 
00136 public:
00139   ClassStream& operator << ( const ParametricPlane *parametricPlane );
00140 
00145   ClassStream& operator << ( const ParametricPlane& parametricPlane )
00146   { return (*this) << &parametricPlane; }
00147   
00149   ClassStream& operator >> ( ParametricPlane*& parametricPlane );
00150 
00153   ClassStream& operator << ( const LandmarkList *landmarkList );
00154 
00159   ClassStream& operator << ( const LandmarkList& landmarkList )
00160   { return (*this) << &landmarkList; }
00161   
00163   ClassStream& operator >> ( LandmarkList::SmartPtr& landmarkList );
00164 };
00165 
00167 
00168 } // namespace cmtk
00169 
00170 #endif // #ifndef __cmtkClassStream_h_included_
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines