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

Calculation.h

Go to the documentation of this file.
00001 #ifndef CalculationH
00002 #define CalculationH
00003 /*******************************************************************************
00004 Copyright 2002,2003 Petr Kulhanek
00005 
00006     This file is part of Core plugin.
00007 
00008     Core plugin is free software; you can redistribute it and/or modify
00009     it under the terms of the GNU General Public License as published by
00010     the Free Software Foundation; either version 2 of the License, or
00011     (at your option) any later version.
00012 
00013     Core plugin is distributed in the hope that it will be useful,
00014     but WITHOUT ANY WARRANTY; without even the implied warranty of
00015     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016     GNU General Public License for more details.
00017 
00018     You should have received a copy of the GNU General Public License
00019     along with Core plugin; if not, write to the Free Software
00020     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00021 *******************************************************************************/
00022 /*******************************************************************************
00023 ** PROJECT:             Project NEMESIS
00024 ** FILE:                Calculation
00025 ** FUNCTION:            capsulate all data about calculation
00026 ** VERSION:             1.0
00027 ** LANGUAGE:            CBuilder C++
00028 ** TARGET COMPUTER:     IBM PC
00029 ** PROGRAMMER:          Petr Kulhánek
00030 ** HISTORY:
00031 VERSION DATE        NOTE
00032 1.0     2002-07-29
00033 2.0     2003-01-03  implementation of individual constraints lists for jobs
00034 *******************************************************************************/
00035 
00039 /* HEADER FILES ***************************************************************/
00040 
00041 #include "CoreMainHeader.h"
00042 #include "ExtObject.h"
00043 #include "XMLFile.h"
00044 #include "TemplList.h"
00045 #include "ContainerEnumerator.h"
00046 #include "MoleculeInfo.h"
00047 #include "Property.h"
00048 #include "Job.h"
00049 
00050 /* HEDER FILES END ************************************************************/
00051 
00052 class CCalculationProject;
00053 class CJobEnumerator;
00054 class CPluginObjectInfo;
00055 class CExtUUID;
00056 class CMolecule;
00057 class CAtomType;
00058 
00059 //---------------------------------------------------------------------------
00060 
00062 
00065 class NEMESIS_CORE_PACKAGE CCalculation : public CExtObject {
00066     public:
00067         __fastcall  CCalculation(CCalculationProject* owner,CMolecule* p_mol);
00068         __fastcall  ~CCalculation(void);
00069 
00070  // load and save whole calculation data to XML format
00071     bool __fastcall Load(const CSmallString& fullname);
00072     bool __fastcall Save(const CSmallString& fullname);
00073 
00074  // this is used only if the job is started - it update job properties, job itself and core molecule info
00075  // with lock subsystem
00076     bool __fastcall SaveOnlyJob(CJob* p_job);
00077 
00078  // add objects to their list --------------------------------------------------
00079     CJob*           __fastcall AddJob(const CUUID& job_uuid,const CSmallString& name,const CSmallString& descrip,CMoleculeInfo* p_minfo);
00080     CProperty*      __fastcall AddProperty(const CUUID& uuid,const CSmallString& name,const CSmallString& descrip);
00081     CMoleculeInfo*  __fastcall AddMoleculeInfo(EMoleculeInfoType type);
00082     CMoleculeInfo*  __fastcall AddMoleculeInfo(CJob* p_job,int local_id,EMoleculeInfoType type);
00083 
00084  // gets variables of interest -------------------------------------------------
00085     inline CTemplList<CJob>&           __fastcall GetJobsList(void);
00086     inline CTemplList<CProperty>&      __fastcall GetPropertiesList(void);
00087     inline CTemplList<CMoleculeInfo>&  __fastcall GetMoleculeInfoList(void);
00088 
00089     CJob*           __fastcall FindJob(int index);
00090     CJob*           __fastcall FindCharonJob(int ch_id);
00091     CProperty*      __fastcall FindProperty(int index);
00092     CMoleculeInfo*  __fastcall FindMoleculeInfo(int index);
00093 
00094  // get informations ----------------------
00095     inline CMolecule* __fastcall GetMolecule(void);
00096     CExtObject*       __fastcall FindObject(int index);
00097 
00098  // job management -------------------------------------------------------------
00099     bool         __fastcall ActivateJob(CJob* p_job,CMoleculeInfo* p_molinfo=NULL);
00100     inline CJob* __fastcall GetActiveJob(void);
00101     void         __fastcall LockSystem(void);
00102     inline bool  __fastcall IsSystemLocked(void);
00103     void         __fastcall RegisterAllWatch(void);
00104 
00105  // core molecule info function ------------------------------------------------
00106     CMoleculeInfo*      __fastcall GetInitialMoleculeInfo(void);
00107     inline bool         __fastcall IsInitialMoleculeInfo(CMoleculeInfo* info);
00108     inline int          __fastcall GetNumOfAtoms(void);
00109     int                 __fastcall GetAtomicNumber(int index);
00110     const CAtomType&    __fastcall GetAtomType(int index);
00111     int                 __fastcall GetIndexFromAtomIndex(int atom_index);
00112 
00113  // main enumerator object -----------------------------------------------------
00114     CContainerEnumerator* __fastcall GetRootEnumerator(void);
00115     CContainerEnumerator* __fastcall GetRootMolInfoEnumerator(void);
00116 
00117  // project that owns the calculation
00118     __property CAdvancedProject* Project = {read = GetAdvancedProject};
00119 
00120  // section of private data and functions --------------------------------------
00121     private:
00122     CJob*                        ActiveJob;
00123     int                          NumOfLocks; // determine number of running or finished jobs
00124     CTemplList<CJob>             Jobs;       // list of jobs
00125     CTemplList<CProperty>        Properties;
00126     CTemplList<CMoleculeInfo>    Geometries;
00127 
00128     // information about molecule
00129     CMolecule*                   Molecule;
00130     CMoleculeInfo*               InitialGeometry; // first geometry
00131     // this is the core information that cannot be change after first calculation is started
00132     int                          NumOfAtoms;
00133     int*                         AtomicNumbers;
00134     CAtomType*                   MMTypes;
00135 
00136     // information necessary for partial save of job
00137     CSmallString                 FullNameOfXMLFile;
00138 
00139     bool __fastcall UpdateMoleculeCoreInfo(void);
00140     bool __fastcall LoadCoreInfo(CXMLElement* p_el);
00141     bool __fastcall SaveCoreInfo(CXMLElement* p_el);
00142 
00143     inline CAdvancedProject* __fastcall GetAdvancedProject(void);
00144     };
00145 
00146 //---------------------------------------------------------------------------
00147 
00148 DECLARE_EVENT(Calculation_AddJob);
00149 DECLARE_EVENT(Calculation_RemoveJob);
00150 
00151 DECLARE_EVENT(Calculation_AddProperty);
00152 DECLARE_EVENT(Calculation_RemoveProperty);
00153 
00154 DECLARE_EVENT(Calculation_AddMoleculeInfo);
00155 DECLARE_EVENT(Calculation_RemoveMoleculeInfo);
00156 
00157 DECLARE_EVENT(Calculation_ActivateJob);
00158 DECLARE_EVENT(Calculation_ActivateGeometry);
00159 
00160 DECLARE_EVENT(Calculation_SetLock);
00161 
00162 //---------------------------------------------------------------------------
00163 
00165 
00168 class NEMESIS_CORE_PACKAGE CCalculationEnumerator : public CContainerEnumerator {
00169     public:
00170         __fastcall CCalculationEnumerator(CComObject* owner,CCalculation* p_cal);
00171         __fastcall ~CCalculationEnumerator(void);
00172 
00173     virtual int __fastcall NumOfCommands(void);
00174     virtual CSmallString __fastcall GetCommand(int i,bool& enabled);
00175     virtual bool __fastcall DoCommand(int i);
00176 
00177     virtual int         __fastcall NumOfObjects(void);
00178     virtual CExtObject* __fastcall GetObject(int pos);
00179 
00180     virtual CContainerEnumerator* __fastcall GetFirstSubContainer(void);
00181     virtual CContainerEnumerator* __fastcall GetNextSubContainer(void);
00182 
00183     virtual bool __fastcall ContainSubContainers(void);
00184 
00185     virtual int __fastcall NumOfColumns(void);  // počet sloupců popisujících objekt
00186     virtual const CSmallString __fastcall GetColumnCaption(int index); // popis sloupce
00187     virtual const CSmallString __fastcall GetObjectProperty(int index); // vlastnost objektu
00188     virtual int __fastcall GetObjectImageIndex(void);
00189     virtual CExtObject* __fastcall GetCurrentObject(void);
00190     virtual bool __fastcall SetCurrentObject(CExtObject* p_object);
00191 
00192     private:
00193     CSimpleList<CJobEnumerator>     SubContainers;
00194     CSimpleIterator<CJobEnumerator> Pointer;
00195     CCalculation*                   Calculation;
00196     CJobEnumerator*                 CurrentObject;
00197     bool                            Changed;
00198 
00199     void __fastcall PrepareImageIndex(void);
00200     bool __fastcall PrepareSubContainers(void);
00201     void __fastcall ProcessEvent(const CEventIdentifier& event,CExtObject* Sender,void* p_data);
00202     };
00203 
00204 //---------------------------------------------------------------------------
00205 
00206 extern CPluginObjectInfo CalculationEnumObjectInfo;
00207 extern CExtUUID          ID_CalculationEnum;
00208 
00209 //---------------------------------------------------------------------------
00210 
00212 
00215 class NEMESIS_CORE_PACKAGE CCalculationMolInfoEnumerator : public CContainerEnumerator {
00216     public:
00217         __fastcall CCalculationMolInfoEnumerator(CComObject* owner,CCalculation* p_cal);
00218         __fastcall ~CCalculationMolInfoEnumerator(void);
00219 
00220     virtual int __fastcall NumOfCommands(void);
00221     virtual CSmallString __fastcall GetCommand(int i,bool& enabled);
00222     virtual bool __fastcall DoCommand(int i);
00223 
00224     virtual int         __fastcall NumOfObjects(void);
00225     virtual CExtObject* __fastcall GetObject(int pos);
00226 
00227     virtual CContainerEnumerator* __fastcall GetFirstSubContainer(void);
00228     virtual CContainerEnumerator* __fastcall GetNextSubContainer(void);
00229 
00230     virtual bool __fastcall ContainSubContainers(void);
00231 
00232     virtual int __fastcall NumOfColumns(void);  // počet sloupců popisujících objekt
00233     virtual const CSmallString __fastcall GetColumnCaption(int index); // popis sloupce
00234     virtual const CSmallString __fastcall GetObjectProperty(int index); // vlastnost objektu
00235     virtual int __fastcall GetObjectImageIndex(void);
00236     virtual CExtObject* __fastcall GetCurrentObject(void);
00237     virtual bool __fastcall SetCurrentObject(CExtObject* p_object);
00238 
00239     private:
00240     CSimpleList<CContainerEnumerator>       SubContainers;
00241     CSimpleIterator<CContainerEnumerator>   Pointer;
00242     CCalculation*                           Calculation;
00243     CContainerEnumerator*                   CurrentObject;
00244     bool                                    Changed;
00245 
00246     void __fastcall PrepareImageIndex(void);
00247     bool __fastcall PrepareSubContainers(void);
00248     void __fastcall ProcessEvent(const CEventIdentifier& event,CExtObject* Sender,void* p_data);
00249     };
00250 
00251 //---------------------------------------------------------------------------
00252 
00253 extern CPluginObjectInfo CalculationMolInfoEnumObjectInfo;
00254 extern CExtUUID          ID_CalculationMolInfoEnum;
00255 
00256 /* INLINE FUNCTIONS ***********************************************************/
00257 
00258 inline CAdvancedProject* __fastcall CCalculation::GetAdvancedProject(void)
00259 {
00260  return((CAdvancedProject*)GetProject());
00261 }
00262 
00263 //---------------------------------------------------------------------------
00264 
00265 inline CJob* __fastcall CCalculation::GetActiveJob(void)
00266 {
00267  return(ActiveJob);
00268 }
00269 
00270 //---------------------------------------------------------------------------
00271 
00272 inline CMolecule* __fastcall CCalculation::GetMolecule(void)
00273 {
00274  return(Molecule);
00275 }
00276 
00277 //---------------------------------------------------------------------------
00278 
00279 inline bool __fastcall CCalculation::IsInitialMoleculeInfo(CMoleculeInfo* info)
00280 {
00281  return(InitialGeometry == info);
00282 }
00283 
00284 //---------------------------------------------------------------------------
00285 
00286 inline CTemplList<CJob>& __fastcall CCalculation::GetJobsList(void)
00287 {
00288  return(Jobs);
00289 }
00290 
00291 //---------------------------------------------------------------------------
00292 
00293 inline CTemplList<CProperty>& __fastcall CCalculation::GetPropertiesList(void)
00294 {
00295  return(Properties);
00296 }
00297 
00298 //---------------------------------------------------------------------------
00299 
00300 inline CTemplList<CMoleculeInfo>&  __fastcall CCalculation::GetMoleculeInfoList(void)
00301 {
00302  return(Geometries);
00303 }
00304 
00305 //---------------------------------------------------------------------------
00306 
00307 inline int __fastcall CCalculation::GetNumOfAtoms(void)
00308 {
00309  return(NumOfAtoms);
00310 }
00311 
00312 //---------------------------------------------------------------------------
00313 
00314 inline bool __fastcall CCalculation::IsSystemLocked(void)
00315 {
00316  return(NumOfLocks>0);
00317 }
00318 
00319 //---------------------------------------------------------------------------
00320 
00321 /* INLINE FUNCTIONS END *******************************************************/
00322 
00323 #endif

Generated on Sun Feb 9 12:53:50 2003 for NemesisCore by doxygen1.3-rc2