Changeset 852 for trunk/MagicSoft/Mars/mbase
- Timestamp:
- 06/20/01 10:41:23 (23 years ago)
- Location:
- trunk/MagicSoft/Mars/mbase
- Files:
-
- 4 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/mbase/BaseLinkDef.h
r843 r852 29 29 30 30 #pragma link C++ class MReadTree; 31 #pragma link C++ class MWriteFile; 31 32 #pragma link C++ class MWriteAsciiFile; 33 #pragma link C++ class MWriteRootFile; 32 34 33 35 #pragma link C++ class MArray; -
trunk/MagicSoft/Mars/mbase/MEvtLoop.cc
r843 r852 160 160 // 161 161 if (maxcnt<0) 162 while (fTaskList->Process() && ++dummy); 162 // process first and increment if sucessfull 163 while (fTaskList->Process()) dummy++; 163 164 else 164 while (fTaskList->Process() && dummy--); 165 // check for number and break if unsuccessfull 166 while (dummy-- && fTaskList->Process()); 165 167 166 168 // -
trunk/MagicSoft/Mars/mbase/MParList.cc
r847 r852 102 102 Bool_t MParList::AddToList(MParContainer *obj, MParContainer *where) 103 103 { 104 // 105 // check if the object (you want to add) exists 106 // 107 108 if (!obj) return kTRUE; 109 110 *fLog << "Adding " << obj->GetName() << " to " << GetName() << "... " << flush; 104 111 // 105 // check if the object (you want to add) exists 106 // 107 108 if (!obj) return kTRUE; 109 110 *fLog << "Adding " << obj->GetName() << " to " << GetName() << "... " << flush; 111 // 112 // check if it is in the list yet 113 // 114 if (fContainer.FindObject(obj)) 115 { 116 *fLog << dbginf << "Container already added" << endl; 117 return kTRUE; 118 } 119 120 // 121 // check if you want to add the new parameter container somewhere 112 // check if it is in the list yet 113 // 114 if (fContainer.FindObject(obj)) 115 { 116 *fLog << dbginf << "Container already added" << endl; 117 return kTRUE; 118 } 119 120 // 121 // check if you want to add the new parameter container somewhere 122 122 // special (in that case you specify "where") 123 //124 if (where)125 {126 if (!fContainer.FindObject(where))127 {128 *fLog << dbginf << "Cannot find parameter container after which the new one should be added!" << endl;129 return kFALSE;130 }131 }132 133 fContainer.Add(obj);134 *fLog << "Done." << endl;135 136 return kTRUE;123 // 124 if (where) 125 { 126 if (!fContainer.FindObject(where)) 127 { 128 *fLog << dbginf << "Cannot find parameter container after which the new one should be added!" << endl; 129 return kFALSE; 130 } 131 } 132 133 fContainer.Add(obj); 134 *fLog << "Done." << endl; 135 136 return kTRUE; 137 137 } 138 138 -
trunk/MagicSoft/Mars/mbase/MWriteAsciiFile.cc
r850 r852 64 64 fNameFile = filename; 65 65 fNameContainer = contname; 66 67 fOut = new ofstream(fNameFile); 66 68 } 67 69 … … 80 82 fNameFile = filename; 81 83 fNameContainer = cont->GetName(); 84 85 fOut = new ofstream(fNameFile); 82 86 } 83 87 … … 89 93 MWriteAsciiFile::~MWriteAsciiFile() 90 94 { 91 if (fOut) 92 delete fOut; 95 delete fOut; 93 96 } 94 97 95 98 // -------------------------------------------------------------------------- 96 99 // 97 // Tries to open the given output file. And tries to get a pointer to the 98 // instance of the container which should be written. 99 // If the container has already the HasChanged flag it is immediatly written 100 // to the output file. 100 // Check if our container is ready for writing. If so write it. 101 101 // 102 Bool_t MWriteAsciiFile::PreProcess (MParList *pList) 102 void MWriteAsciiFile::CheckAndWrite() const 103 { 104 if (fContainer->HasChanged()) 105 fContainer->AsciiWrite(*fOut); 106 } 107 108 // -------------------------------------------------------------------------- 109 // 110 // Return open state of the file 111 // 112 Bool_t MWriteAsciiFile::IsFileOpen() const 113 { 114 return (bool)(*fOut); 115 } 116 117 // -------------------------------------------------------------------------- 118 // 119 // If the container is yet unknown and the name of it is known only, try 120 // to get the container from the parameter list. 121 // 122 Bool_t MWriteAsciiFile::GetContainer(MParList *pList) 103 123 { 104 124 // 105 125 // Try to find the container which should be stored. 106 126 // 107 if (!fContainer) 108 { 109 fContainer = (MParContainer*)pList->FindObject(fNameContainer); 110 if (!fContainer) 111 { 112 *fLog << dbginf << "Cannot find parameter container '" << fContainer << "'." << endl; 113 return kFALSE; 114 } 115 } 127 if (fContainer) 128 return kTRUE; 116 129 117 // 118 // Try to open the output file 119 // 120 fOut = new ofstream(fNameFile); 130 fContainer = (MParContainer*)pList->FindObject(fNameContainer); 131 if (fContainer) 132 return kTRUE; 121 133 122 if (!(*fOut)) 123 { 124 *fLog << dbginf << "Cannot open Ascii file '" << fNameFile << "' for writing." << endl; 125 return kFALSE; 126 } 127 128 *fLog << "Ascii file '" << fNameFile << "' opened for writing." << endl; 129 130 // 131 // write the container if it is already in changed state 132 // 133 if (fContainer->HasChanged()) 134 fContainer->AsciiWrite(*fOut); 135 136 return kTRUE; 134 *fLog << dbginf << "Cannot find parameter container '" << fContainer << "'." << endl; 135 return kFALSE; 137 136 } 138 139 // --------------------------------------------------------------------------140 //141 // Checks if the HasChanged flag of the output container is set. If it is set142 // the container is instructed to write itself to the ascii file.143 // (By calling its memberfunction AsciiWrite. You find the Prototype in144 // MParContainer)145 //146 Bool_t MWriteAsciiFile::Process()147 {148 if (fContainer->HasChanged())149 fContainer->AsciiWrite(*fOut);150 151 return kTRUE;152 }153 154 // --------------------------------------------------------------------------155 //156 // If the output container has the HasChanged flag set, it is written to the157 // output file (eg. this could be some calculated result)158 // If the output file object exists, delete it. (The file is closed159 // automatically in the corresponding destructor)160 //161 Bool_t MWriteAsciiFile::PostProcess()162 {163 //164 // check if the container changed state is set165 //166 if (fContainer->HasChanged())167 fContainer->AsciiWrite(*fOut);168 169 //170 // delete (close) file171 //172 delete fOut;173 fOut = NULL;174 175 return kTRUE;176 }177 -
trunk/MagicSoft/Mars/mbase/MWriteAsciiFile.h
r850 r852 2 2 #define MWRITEASCIIFILE_H 3 3 4 #ifndef M TASK_H5 #include "M Task.h"4 #ifndef MWRITEFILE_H 5 #include "MWriteFile.h" 6 6 #endif 7 7 8 class MWriteAsciiFile : public M Task8 class MWriteAsciiFile : public MWriteFile //MTask 9 9 { 10 10 private: … … 16 16 MParContainer *fContainer; 17 17 18 virtual void CheckAndWrite() const; 19 virtual Bool_t IsFileOpen() const; 20 virtual Bool_t GetContainer(MParList *pList); 21 virtual const char *GetFileName() const { return fNameFile; } 22 23 18 24 public: 19 25 MWriteAsciiFile(const char *filename, const char *contname, … … 23 29 ~MWriteAsciiFile(); 24 30 25 Bool_t PreProcess(MParList *pList);26 Bool_t Process();27 Bool_t PostProcess();28 29 31 ClassDef(MWriteAsciiFile, 0) // Class to write one container to an ascii file 30 32 }; -
trunk/MagicSoft/Mars/mbase/Makefile
r846 r852 38 38 MEvtLoop.cc \ 39 39 MReadTree.cc \ 40 MWriteFile.cc \ 40 41 MWriteAsciiFile.cc \ 42 MWriteRootFile.cc \ 41 43 MArray.cc \ 42 44 MArrayB.cc \
Note:
See TracChangeset
for help on using the changeset viewer.