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

StructureUnit.h

Go to the documentation of this file.
00001 #ifndef StructureUnitH
00002 #define StructureUnitH
00003 
00004 /*******************************************************************************
00005 Copyright 2000,2001,2002 Petr Kulhanek
00006 
00007     This file is part of Core plugin.
00008 
00009     Core plugin is free software; you can redistribute it and/or modify
00010     it under the terms of the GNU General Public License as published by
00011     the Free Software Foundation; either version 2 of the License, or
00012     (at your option) any later version.
00013 
00014     Core plugin is distributed in the hope that it will be useful,
00015     but WITHOUT ANY WARRANTY; without even the implied warranty of
00016     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017     GNU General Public License for more details.
00018 
00019     You should have received a copy of the GNU General Public License
00020     along with Core plugin; if not, write to the Free Software
00021     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00022 *******************************************************************************/
00023 /*******************************************************************************
00024 ** COPYRIGHT (C):       1998,1999,2000 All Rights Reserved
00025 ** PROJEKT:             Projekt NEMESIS
00026 ** SOUBOR:              StructureUnit
00027 ** úČEL:                slouží pro popis a manipulaci se strukturní jednotkou
00028 ** VERZE:               1.0
00029 ** JAZYK:               CBuilder C++
00030 ** CÍLOVÝ POČÍTAČ:      IBM PC
00031 ** PROGRAMÁTOR:         Petr Kulhánek
00032 ** HISTORIE úPRAV:
00033 VERZE   DATUM       POZNÁMKA
00034 1.0             2000-11-30      vznik modulu
00035 *******************************************************************************/
00036 
00040 /* HLAVIČKOVÉ SOUBORY *********************************************************/
00041 
00042 #include "CoreMainHeader.h"
00043 #include "Atom.h"
00044 #include "ContainerEnumerator.h"
00045 #include "IndexCounter.h"
00046 
00047 /* KONEC HLAVIČKOVÝCH SOUBORů *************************************************/
00048 
00049 class CElementsRecord;
00050 class CMolecule;
00051 class CAtom;
00052 class CStructureUnitsList;
00053 class CStructureUnit;
00054 
00055 /* DEFINICE TŘÍD **************************************************************/
00056 
00058 
00061 class NEMESIS_CORE_PACKAGE CStructureUnitData {
00062         public:
00063  // konstruktor a destruktor ---------------------------------------------------
00064         __fastcall CStructureUnitData(void);
00065         __fastcall ~CStructureUnitData(void);
00066 
00067  // vstupně - výstuptní operace ------------------------------------------------
00068     friend ostream& __fastcall operator << (ostream& str,const CStructureUnitData& su);
00069     friend istream& __fastcall operator >> (istream& str,CStructureUnitData& su);
00070 
00071  // inicializace dat a obnova dat ----------------------------------------------
00072     void                        __fastcall GetFromStructureUnit(CStructureUnit* unit);
00073     CStructureUnit* __fastcall MakeStructureUnit(CMolecule* molecule,CElementsRecord* history=NULL);
00074     inline int          __fastcall GetStructureUnitIndex(void) const;
00075 
00076     void __fastcall SetNumOfAtoms(int atoms);
00077 
00078  // sekce soukromých dat -------------------------------------------------------
00079     public:
00080     CExtUUID                    ExtUUID;                        // uuid objektu
00081     int                                 StructureUnitIndex;     // index jednotky
00082     CSmallString                Name;               // jméno jednotky
00083     CSmallString                Description;        // popis jednotky
00084     CSmallString        UnitName;           // jméno jednotky
00085     CExtObject::CStatus Status;             // status jednotky
00086     int                                 NumOfAtoms;         // počet atomů v jednotce
00087     int*                                AtomsIndexArea;         // pole indexů tvořící strukturní jednotku
00088     };
00089 
00090 //------------------------------------------------------------------------------
00091 
00093 
00096 class NEMESIS_CORE_PACKAGE CStructureUnit : public CExtObject{
00097     public:
00098  // konstrukce - destrukce objektu ---------------------------------------------
00099                         __fastcall CStructureUnit(CStructureUnitsList* baselist,CPluginObjectInfo* objectinfo);
00100             __fastcall ~CStructureUnit(void);
00101     void        __fastcall RemoveFromBaseList(CElementsRecord* history=NULL);
00102 
00103  // operace zaznamenávané do historylistu --------------------------------------
00104     bool __fastcall Delete(void); // odstraní strukturní jednotku
00105 
00106  // zjišťovací metody ----------------------------------------------------------
00107         bool                                    __fastcall IsModified(void);    // zjistí zda byla jednotka modifikována
00108     inline CMolecule*           __fastcall GetMolecule(void);
00109     CSmallString                __fastcall GetFullUnitName(void);
00110     inline const CSmallString&  __fastcall GetUnitName(void);
00111     inline void                 __fastcall SetUnitName(const CSmallString& name);
00112     inline void                 __fastcall SetUnitID(int unit_id);
00113     inline int                  __fastcall GetUnitID(void);
00114 
00115  // registrování a odregistrování atomu ze strukturní jednotky -----------------
00116     bool        __fastcall RegisterAtom(CAtom* atom,int index);
00117     bool        __fastcall UnregisterAtom(int index);
00118     void        __fastcall SetNumOfAtoms(int atoms);
00119     inline int  __fastcall GetNumOfAtoms(void);
00120     CAtom*      __fastcall GetAtom(int index);
00121 
00122  // metody - uložení a načtení unitu -------------------------------------------
00123     bool __fastcall Load(CXMLElement* p_el);
00124     bool __fastcall Save(CXMLElement* p_el);
00125 
00126     virtual void __fastcall RemoveFromRegistered(CExtObject* object,CElementsRecord* history=NULL);
00127 
00128  // sekce soukromých dat -------------------------------------------------------
00129     protected:
00130     CStructureUnitsList* FBaselist;         // výchozí list
00131     CSmallString        FUnitName;          // jméno jednotky
00132     int                                 NumOfAtoms;         // počet atomů v jednotce
00133     CAtom**                             AtomsArea;                  // pole atomů tvořící strukturní jednotku
00134     bool                Modified;           // jednotka je modifikovana
00135     int                 UnitID;
00136     friend class CStructureUnitData;
00137     };
00138 
00139 //------------------------------------------------------------------------------
00140 
00141 DECLARE_EVENT(StructureUnit_IsModified);
00142 
00143 //------------------------------------------------------------------------------
00144 
00146 
00149 class NEMESIS_CORE_PACKAGE CStructureUnitsList : public CExtObject, public CTemplList<CStructureUnit> {
00150     public:
00151  // konstruktor a destruktor ---------------------------------------------------
00152         __fastcall CStructureUnitsList(CMolecule* molecule);
00153 
00154  // vkládání strukturní jednotky -----------------------------------------------
00155         CStructureUnit* __fastcall AddStructureUnit(CStructureUnitData& data,CElementsRecord* history=NULL);
00156         CStructureUnit* __fastcall AddStructureUnit(const CUUID& uuid);
00157 
00158  // zjišťování vlastností ------------------------------------------------------
00159         __property CMolecule* Molecule = {read = FMolecule};
00160 
00161     bool __fastcall Load(CXMLElement* p_el);
00162     bool __fastcall Save(CXMLElement* p_el);
00163 
00164     public:
00165     CIndexCounter   NameIndexer;    // base counter for structure unit name index
00166 
00167  // sekce soukromých dat -------------------------------------------------------
00168     private:
00169     CMolecule*      FMolecule;  // mother molecule
00170     };
00171 
00172 // -----------------------------------------------------------------------------
00173 
00174 DECLARE_EVENT(StructureUnitsList_AddStructureUnit);
00175 DECLARE_EVENT(StructureUnitsList_RemoveStructureUnit);
00176 
00177 // ----------------------------------------------------------------------------
00178 // ############################################################################
00179 // ----------------------------------------------------------------------------
00180 
00181 extern CPluginObjectInfo StructureUnitEnumObjectInfo;
00182 extern CExtUUID          ID_StructureUnitEnum;
00183 
00184 // ----------------------------------------------------------------------------
00185 
00187 
00190 class CStructureUnitEnumerator : public CContainerEnumerator {
00191     public:
00192         __fastcall CStructureUnitEnumerator(CComObject* owner,CMolecule* molecule);
00193 
00194     virtual int __fastcall NumOfCommands(void);
00195     virtual CSmallString __fastcall GetCommand(int i,bool& enabled);
00196     virtual bool __fastcall DoCommand(int i);
00197 
00198  // sekce zabývající se popisem objektů v kontejneru ---------------------------
00199     virtual int         __fastcall NumOfObjects(void);
00200     virtual bool        __fastcall PrepareObjects(int startpos,int size,int rstart,int rend);
00201     virtual CExtObject* __fastcall GetObject(int pos);
00202 
00203  // funkce pro rozšířený popis objektů a kontejnerů ----------------------------
00204     virtual int __fastcall NumOfColumns(void);  // počet sloupců popisujících objekt
00205     virtual const CSmallString __fastcall GetColumnCaption(int index); // popis sloupce
00206     virtual const CSmallString __fastcall GetObjectProperty(int index); // vlastnost objektu
00207     virtual int __fastcall GetObjectImageIndex(void);
00208 
00209     virtual void __fastcall ProcessEvent(const CEventIdentifier& event,CExtObject* Sender,void* p_data);
00210 
00211     virtual CExtObject* __fastcall GetCurrentObject(void);
00212     virtual bool        __fastcall SetCurrentObject(CExtObject* p_object);
00213 
00214     private:
00215     CStructureUnitsList*             StructureUnits;
00216     CTemplIterator<CStructureUnit>   Pointer;
00217     CStructureUnit*                  CurrentObject;
00218     int                              StartPos;
00219     int                              EndPos;
00220     bool                             Changed;
00221     CSimpleList<CStructureUnit>      CurrentView;
00222     };
00223 
00224 // ----------------------------------------------------------------------------
00225 
00226 extern CPluginObjectInfo SingleStructureUnitEnumObjectInfo;
00227 extern CExtUUID          ID_SingleStructureUnitEnum;
00228 
00229 // ----------------------------------------------------------------------------
00230 
00232 
00235 class CSingleStructureUnitEnumerator : public CContainerEnumerator {
00236     public:
00237         __fastcall CSingleStructureUnitEnumerator(CComObject* owner,CStructureUnit* p_str);
00238 
00239     virtual int __fastcall NumOfCommands(void);
00240     virtual CSmallString __fastcall GetCommand(int i,bool& enabled);
00241     virtual bool __fastcall DoCommand(int i);
00242 
00243  // sekce zabývající se popisem objektů v kontejneru ---------------------------
00244     virtual int         __fastcall NumOfObjects(void);
00245     virtual CExtObject* __fastcall GetObject(int pos);
00246 
00247  // funkce pro rozšířený popis objektů a kontejnerů ----------------------------
00248     virtual int __fastcall NumOfColumns(void);  // počet sloupců popisujících objekt
00249     virtual const CSmallString __fastcall GetColumnCaption(int index); // popis sloupce
00250     virtual const CSmallString __fastcall GetObjectProperty(int index); // vlastnost objektu
00251     virtual int __fastcall GetObjectImageIndex(void);
00252 
00253     virtual void __fastcall ProcessEvent(const CEventIdentifier& event,CExtObject* Sender,void* p_data);
00254 
00255     virtual CExtObject* __fastcall GetCurrentObject(void);
00256     virtual bool        __fastcall SetCurrentObject(CExtObject* p_object);
00257 
00258     private:
00259     CStructureUnit*  StructureUnit;
00260     CAtom*           CurrentObject;
00261     bool             Changed;
00262     };
00263 
00264 // ----------------------------------------------------------------------------
00265 // ############################################################################
00266 // ----------------------------------------------------------------------------
00267 
00268 /*  TŘÍDA: CStructureUnitDataHistory
00269     ÚČEL:  slouží pro záznam změn souvisejících s destrukcí či vznikem CStructureUnit
00270 */
00271 
00272 class CStructureUnitDataHistory : public CElementData{
00273         public:
00274                                 __fastcall CStructureUnitDataHistory(CStructureUnit* p_unit,bool create);
00275 
00276     private:
00277     virtual void        __fastcall Forward(void);
00278     virtual void        __fastcall Backward(void);
00279 
00280     CStructureUnitData  Data;
00281     CMolecule*                  Molecule;
00282     CStructureUnit*             Unit;
00283     };
00284 
00285 // ----------------------------------------------------------------------------
00286 // ############################################################################
00287 // ----------------------------------------------------------------------------
00288 
00289 class CStructureUnitUnregHistory: public CElementData{
00290     public:
00291     __fastcall CStructureUnitUnregHistory(CStructureUnit* p_str,CAtom* p_atom,int index,bool regobject);
00292 
00293     private:
00294     CMolecule*  Molecule;
00295     int         StructureUnitIndex;
00296     int         AtomIndex;
00297     int         AtomPositionIndex;
00298 
00299     virtual void __fastcall Forward(void);
00300     virtual void __fastcall Backward(void);
00301     };
00302 
00303 /* KONEC DEFINICE TŘÍD ********************************************************/
00304 
00305 inline int __fastcall CStructureUnitData::GetStructureUnitIndex(void) const
00306 {
00307  return(StructureUnitIndex);
00308 }
00309 
00310 // -----------------------------------------------------------------------------
00311 
00312 inline CMolecule* __fastcall CStructureUnit::GetMolecule(void)
00313 {
00314  return(FBaselist->Molecule);
00315 }
00316 
00317 // -----------------------------------------------------------------------------
00318 
00319 inline int __fastcall CStructureUnit::GetNumOfAtoms(void)
00320 {
00321  return(NumOfAtoms);
00322 }
00323 
00324 // -----------------------------------------------------------------------------
00325 
00326 inline const CSmallString&  __fastcall CStructureUnit::GetUnitName(void)
00327 {
00328  return(FUnitName);
00329 }
00330 
00331 // -----------------------------------------------------------------------------
00332 
00333 inline void __fastcall CStructureUnit::SetUnitName(const CSmallString& name)
00334 {
00335  FUnitName = name;
00336 }
00337 
00338 // -----------------------------------------------------------------------------
00339 
00340 inline void __fastcall CStructureUnit::SetUnitID(int unit_id)
00341 {
00342  UnitID = unit_id;
00343 }
00344 
00345 // -----------------------------------------------------------------------------
00346 
00347 inline int __fastcall CStructureUnit::GetUnitID(void)
00348 {
00349  return(UnitID);
00350 }
00351 
00352 // -----------------------------------------------------------------------------
00353 
00354 #endif

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