Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members  

ExtentFileDescriptor.h

Go to the documentation of this file.
00001 /*
00002     Extent File System - Volume data file storage
00003     Copyright (C) 2000-2002 Sebastian Gerlach EPFL-LSP
00004 
00005     This program is free software; you can redistribute it and/or modify
00006     it under the terms of the GNU General Public License as published by
00007     the Free Software Foundation; either version 2 of the License, or
00008     (at your option) any later version.
00009   
00010     This program is distributed in the hope that it will be useful,
00011     but WITHOUT ANY WARRANTY; without even the implied warranty of
00012     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013     GNU General Public License for more details.
00014     
00015     You should have received a copy of the GNU General Public License
00016     along with this program; if not, write to the Free Software
00017     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00018 */
00019 
00020 #ifndef __EXTENTFILEDESC_H
00021 #define __EXTENTFILEDESC_H
00022 
00023 #include <string.h>
00024 #include <libxml/xmlmemory.h>
00025 #include <libxml/parser.h>
00026 
00027 typedef unsigned char UInt8;
00028 typedef unsigned short UInt16;
00029 typedef unsigned int UInt32;
00030 typedef int Int32;
00031 typedef __int64 Int64;
00032 
00033 namespace extfile
00034 {
00036     typedef UInt32 (*StripeFunc)(UInt32 in, UInt32 sc);
00037     
00039     const Int32 MAXSTRIPES = 16;
00041     const Int32 MAXZOOM = 16;
00043     const Int32 MAXCHANNELS = 16;
00044     
00045 #ifndef __CAP2_BASE_H
00046 
00047     class StringA
00048     {
00049         char *value;
00050     public:
00051         StringA() { value=NULL; }
00052         StringA(const char *v) { value=NULL;    if(v) { value=new char[strlen(v)+1]; strcpy(value,v); } }
00053         StringA(const StringA &v) { value=NULL; if(v.value) { value=new char[strlen(v.value)+1]; strcpy(value,v.value); } }
00054         StringA(const StringA *v) { value=NULL; if(v && v->value) { value=new char[strlen(v->value)+1]; strcpy(value,v->value); } }
00055         ~StringA() { if(value) delete value; }
00056         Int32 length() { return value ? strlen(value) : 0; }
00057         bool isNull() { return value==NULL; }
00058         
00059         StringA& operator=(char *val) { if(value) delete value; value=NULL; if(val) { value=new char[strlen(val)+1]; strcpy(value,val); } return *this; }
00060         StringA& operator=(const StringA& val) { if(value) delete value; value=NULL; if(val.value) { value=new char[strlen(val.value)+1]; strcpy(value,val.value); } return *this; }
00061         StringA& operator=(const StringA* val) { if(value) delete value; value=NULL; if(val && val->value) { value=new char[strlen(val->value)+1]; strcpy(value,val->value); } return *this; }
00062         operator const char *() { return value ? value : "(null)"; }
00063     };
00064 #endif
00065     
00067     template<class et> struct Vector
00068     {
00069         et x;   
00070         et y;   
00071         et z;   
00072         
00074         Vector() { x=y=z=0; }
00076         et convert(const char *a);
00078         bool loadFromXML(xmlDocPtr doc, xmlNodePtr cur);
00079     };
00080     
00081     template<class et> bool Vector<et>::loadFromXML(xmlDocPtr doc, xmlNodePtr cur)
00082     {
00083         cur=cur->xmlChildrenNode;
00084         while(cur!=NULL) 
00085         {
00086             if ((!xmlStrcmp(cur->name, (const xmlChar *)"x")))
00087                 x=convert((char*)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1));
00088             if ((!xmlStrcmp(cur->name, (const xmlChar *)"y")))
00089                 y=convert((char*)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1));
00090             if ((!xmlStrcmp(cur->name, (const xmlChar *)"z")))
00091                 z=convert((char*)xmlNodeListGetString(doc, cur->xmlChildrenNode, 1));
00092             cur = cur->next;
00093         }
00094         return true;
00095     }
00096     
00098     class Stripe
00099     {
00100     public:
00101         StringA host;       
00102         StringA path;       
00103         StringA share;      
00104         StringA index;      
00105         StringA data;       
00106         Int64 segment;      
00107         
00109         bool loadFromXML(xmlDocPtr doc, xmlNodePtr cur);
00110         
00112         Stripe()
00113         {
00114             segment=0;
00115         }
00116     };
00117     
00119     class FilePattern
00120     {
00121     public:
00122         StringA name;   
00123         StringA format; 
00124         Int32 channel;  
00125         Int32 width;    
00126         Int32 height;   
00127         Int32 offset;   
00128         Int32 count;    
00129 
00131         FilePattern()
00132         {
00133             channel=0; width=0; height=0; offset=0; count=0;
00134         }
00135         
00137         bool loadFromXML(xmlDocPtr doc, xmlNodePtr cur);
00138     };
00139     
00141     struct AddressEntry
00142     {
00143         Int32 offset;   
00144         Int32 length;   
00145     };
00146     
00148     class ExtentFileDescriptor
00149     {
00150     public:
00151         enum { 
00152             FATX        = 0x00000001,   
00153             FATY        = 0x00000002,   
00154             FATZ        = 0x00000004,   
00155             COMPRESSED  = 0x00010000,   
00156         };
00157         enum {
00158             INVALID     = 0,        
00159             R8G8B8      = 1,        
00160             R5G6B5      = 2,        
00161             G8          = 3,        
00162             G16         = 4,        
00163             L16         = 5,        
00164             X8R8G8B8    = 6,        
00165             L16_BIG     = 7,        
00166             B8G8R8X8    = 8,        
00167         };
00169         int channelSize(int s) 
00170         { 
00171             static const int cs[]={0,3,2,1,2,2,4,2,4};
00172             return cs[s];
00173         }
00174         
00176         StringA name;
00178         StringA comment;
00180         StringA origin;
00181         
00183         Stripe stripes[MAXSTRIPES];
00185         Int32 stripeCount;
00187         FilePattern sources[MAXCHANNELS];
00189         Int32 flags;
00191         Vector<Int32> datasetSize;
00193         Int32 blockSize;
00195         Int32 resolutions;
00197         Vector<Int32> extentSize;
00199         Vector<Int32> fullExtentSize;
00201         Vector<double> voxelSize;
00203         Int32 channels;
00205         Int32 channelFormat[MAXCHANNELS];
00207         StringA labels;
00208         
00210         Int32 extSize;
00211         
00213         int extOff[MAXZOOM];
00215         int extX[MAXZOOM];
00217         int extY[MAXZOOM];
00219         int extZ[MAXZOOM];
00221         int sizeX[MAXZOOM];
00223         int sizeY[MAXZOOM];
00225         int sizeZ[MAXZOOM];
00226         
00227     public:
00229         ExtentFileDescriptor()
00230         {
00231             name=""; comment=""; origin="";
00232             flags=0;
00233             resolutions=0;
00234             channels=0;
00235             stripeCount=0;
00236             for(int i=0;i<MAXCHANNELS;i++)
00237                 channelFormat[i]=0;
00238         }
00239         
00241         bool loadFromXML(const char *filename);
00242         
00243 #ifdef DECLARE_CONVERT
00244 
00245         void convert(StripeFunc stripefunc);
00246 #endif
00247     };
00248     
00249 }
00250 
00251 #endif

Generated on Wed May 29 11:50:17 2002 for Extent File System by doxygen1.2.12 written by Dimitri van Heesch, © 1997-2001