Output.h

00001 //---------------------------------------------------------------------------
00002 
00003 #ifndef OutputH
00004 #define OutputH
00005 
00006 #include "BehaviorBase.h"
00007 #include "Constants.h"
00008 #include <stdio.h>
00009 
00010 class clGridBase;
00011 class clSimManager;
00012 class clTreeSearch;
00013 
00043 class clOutput : public clBehaviorBase {
00044 
00045   public:
00046 
00052   clOutput(clSimManager *p_oSimManager);
00053 
00057   ~clOutput();
00058 
00064   void Action();
00065 
00071   void GetDetailedOutputFilename(char *cReturnFile)
00072    {sprintf(cReturnFile, "%s%s", m_cFileRoot, DETAILED_OUTPUT_FILE_EXT);};
00073 
00082   void GetTimestepFilename(int iTimestep, char *cFilename);
00083 
00084   protected:
00085 
00091   void GetData(xercesc::DOMDocument *p_oDoc);
00092 
00093   //This is the filename of the detailed output file - any other files by this name
00094   //will be overwritten
00095   char m_cFileRoot[MAX_FILENAME_SIZE], 
00097        m_cTarball[MAX_FILENAME_SIZE];  
00103   struct stcTreeOutputInfo {
00104    short int iSaveFreq;      
00105    short int iSumTimestep;   
00106    short int iNumInts;       
00107    short int iNumFloats;     
00108    short int iNumChars;      
00109    short int iNumBools;      
00110    short int *p_iIntCodes;   
00111    short int *p_iFloatCodes; 
00112    short int *p_iCharCodes;  
00113    short int *p_iBoolCodes;  
00114    bool bSaveThisTimeStep;   
00115   } **mp_treeSettings;  
00121   struct stcGridOutputInfo {
00122    clGridBase *p_oGridPointer;     
00123    short int iSaveFreq;            
00124    short int iSumTimestep;         
00125    short int iNumInts;             
00126    short int iNumFloats;           
00127    short int iNumChars;            
00128    short int iNumBools;            
00129    short int *p_iIntCodes;         
00130    short int *p_iFloatCodes;       
00131    short int *p_iCharCodes;        
00132    short int *p_iBoolCodes;        
00133    short int iNumPackageInts;      
00134    short int iNumPackageFloats;    
00135    short int iNumPackageChars;     
00136    short int iNumPackageBools;     
00137    short int *p_iPackageIntCodes;  
00138    short int *p_iPackageFloatCodes;
00139    short int *p_iPackageCharCodes; 
00140    short int *p_iPackageBoolCodes; 
00141   } *mp_gridSettings; 
00143   short int m_iNumGridsToSave; 
00146   short int m_iNumSpecies;
00147 
00149   short int m_iNumTypes;
00150 
00154   void WriteDetailedOutputHeader();
00155 
00161   void WriteTimestepHeader(const char *cFilename);
00162 
00168   void WriteTimestepFooter(const char *cFilename);
00169 
00175   void WriteTreeData(const char *cFilename);
00176 
00186   void WriteGridData(const char *cFilename);
00187 
00193   void ExtractTreeInfo(xercesc::DOMDocument *p_oDoc);
00194 
00200   void ExtractGridInfo(xercesc::DOMDocument *p_oDoc);
00201 
00211   inline void AddToBuffer(char *cBuf, char *cToAdd, FILE *out, int iBufferSize) {
00212     if (strlen(cToAdd) + strlen(cBuf) > iBufferSize) { //max out buffer?
00213       fwrite(cBuf, strlen(cBuf), 1, out);  //flush the buffer to file
00214       cBuf[0] = '\0';   //reset
00215     }
00216     strcat(cBuf, cToAdd);
00217   }
00218 };
00219 //---------------------------------------------------------------------------
00220 #endif

Generated on Thu Jan 26 13:44:34 2006 for SORTIE Core C++ Documentation by  doxygen 1.4.6-NO