dbelem.h

Go to the documentation of this file.
00001 /**
00002  * \file rvc/dbelem.h
00003  * \brief interface for the RVC::ELEMDBASE class.
00004  *
00005  * \if NODOC
00006  * $Id: dbelem.h_v 1.30 2005/04/05 14:28:50 dwilliss Exp $
00007  *
00008  * $Log: dbelem.h_v $
00009  * Revision 1.30  2005/04/05 14:28:50  dwilliss
00010  * Added a new get object filter
00011  *
00012  * Revision 1.29  2004/05/27 19:48:22  scowan
00013  * Added method to transfer style assignment tables.
00014  *
00015  * Revision 1.28  2003/12/04 21:18:31  scowan
00016  * Added element record compare methodd.
00017  *
00018  * Revision 1.27  2003/10/07 17:34:56  scowan
00019  * Object virtual method changes.
00020  *
00021  * Revision 1.26  2003/09/30 16:52:06  dwilliss
00022  * Doxygen
00023  *
00024  * Revision 1.25  2003/09/25 21:56:37  dwilliss
00025  * doxygen
00026  *
00027  * Revision 1.24  2003/09/15 13:49:45  fileserver!dwilliss
00028  * Doxygen
00029  *
00030  * Revision 1.23  2003/01/21 21:57:21  scowan
00031  * More const.
00032  *
00033  * Revision 1.22  2002/09/16 15:32:26  mju
00034  * Add GetElemType().
00035  *
00036  * Revision 1.21  2002/08/15 17:02:19  scowan
00037  * Fixed inline method.
00038  *
00039  * Revision 1.20  2002/08/13 21:37:13  scowan
00040  * Moved database include file.
00041  *
00042  * Revision 1.19  2002/05/01 15:31:24  scowan
00043  * Added get attachment method.
00044  *
00045  * Revision 1.18  2002/04/19 20:50:30  scowan
00046  * Added another get attached elements.
00047  *
00048  * Revision 1.17  2002/04/15 17:26:20  scowan
00049  * Removed record assignments to attachment item.
00050  *
00051  * Revision 1.16  2002/04/11 20:25:17  mju
00052  * Add flags to GetAttachedRecordNumbers().
00053  *
00054  * Revision 1.15  2002/04/11 19:52:30  mju
00055  * Add GetAttachedRecordNumbers and addl ATTACHMENTITEM ctor.
00056  *
00057  * Revision 1.14  2002/04/11 17:46:21  scowan
00058  * MOved element to its own include file.
00059  *
00060  * Revision 1.13  2002/04/11 17:28:09  scowan
00061  * Fixed stuff.
00062  *
00063  * Revision 1.12  2002/04/11 16:14:57  scowan
00064  * More Mike changes.
00065  *
00066  * Revision 1.11  2002/04/11 15:42:32  scowan
00067  * Added some more classes.
00068  *
00069  * Revision 1.10  2002/04/11 14:18:55  scowan
00070  * Moved from dblist.h.
00071  *
00072  * Revision 1.9  2002/04/09 15:33:59  scowan
00073  * Added open as subobject methods.
00074  *
00075  * Revision 1.8  2002/04/08 20:53:09  scowan
00076  * Added new methods.
00077  *
00078  * Revision 1.7  2002/04/08 16:00:07  scowan
00079  * Name Change.
00080  *
00081  * Revision 1.6  2001/10/08 17:32:46  scowan
00082  * Nothing.
00083  *
00084  * Revision 1.5  2001/06/26 16:53:55  scowan
00085  * Specify issmultiobject() to turn off base class setting.
00086  *
00087  * Revision 1.4  2001/06/14 15:16:01  scowan
00088  * Added to RVC namespace.
00089  *
00090  * Revision 1.3  2001/05/31 19:36:59  scowan
00091  * Added a method to append one list entry to a dbelem.
00092  *
00093  * Revision 1.2  2001/05/25 16:53:56  scowan
00094  * Changed class name.
00095  *
00096  * Revision 1.1  2001/05/24 15:13:17  scowan
00097  * Initial revision
00098  *
00099  * \endif
00100 **/
00101 
00102 //!   \class RVC::DBASE_ELEMENT rvc/dbelem.h
00103 //!   \brief Interface for RVC database objects that support attachment of records to geospatial object "elements".
00104 //!
00105 //!   This includes methods to read, write, append, and modify element-record attachment lists.
00106 //!
00107 //!   RVC Object Types that this class supports: Derived class
00108 //!
00109 //!   Default RVC Object Type for this class: Derived class
00110 //!
00111 //!   Valid parents for this class: Derived class
00112 
00113 #ifndef INC_RVC_DBELEM_H
00114 #define INC_RVC_DBELEM_H
00115 
00116 #ifndef INC_RVC_DBASE_H
00117    #include <rvc/dbase.h>
00118 #endif
00119 
00120 #ifndef INC_RVC_DBTABLE_H
00121    #include <rvc/dbtable.h>
00122 #endif
00123 
00124 #ifndef INC_RVC_ELEMENT_H
00125    #include <rvc/element.h>
00126 #endif
00127 
00128 #ifndef GENERATING_DOXYGEN_OUTPUT
00129 struct DBLISTELMT;
00130 #endif // GENERATING_DOXYGEN_OUTPUT
00131 
00132 namespace RVC {
00133 
00134 #ifndef GENERATING_DOXYGEN_OUTPUT
00135 class GEOSPATIAL;    // Forward declarations
00136 #endif // GENERATING_DOXYGEN_OUTPUT
00137 
00138 
00139 class DBASE_ELEMENT : public DBASE {
00140    public:
00141    
00142       class ATTACHMENTITEM;
00143       class GETOBJFILTER_ISSELECTABLE;
00144       typedef SIMPLE_ARRAY<ATTACHMENTITEM> ATTACHMENTARRAY;
00145       
00146       typedef SIMPLE_ARRAY<DBLISTELMT> DBLIST;
00147       
00148       //! Default constructor
00149       explicit DBASE_ELEMENT (
00150          ELEMTYPE ElemType
00151          );
00152 
00153       //! Copy constructor
00154       DBASE_ELEMENT (
00155          const RVC::DBASE_ELEMENT& rhs
00156          );
00157 
00158       //! Destructor
00159       virtual ~DBASE_ELEMENT (
00160          );
00161 
00162       //! Assignment
00163       RVC::DBASE_ELEMENT& operator= (
00164          const RVC::DBASE_ELEMENT& rhs
00165          );
00166          
00167       //! Attach the record to the element
00168       ERRVALUE AddAttachment (
00169          const RVC::ELEMENT& elem,
00170          const RVC::DBASE_ELEMENT::ATTACHMENTITEM& item
00171          );
00172 
00173       //! Attach the array of records to the element
00174       ERRVALUE AddAttachments (
00175          const RVC::ELEMENT& elem,
00176          const RVC::DBASE_ELEMENT::ATTACHMENTARRAY& items
00177          );
00178 
00179       //! Append list entries to this element.
00180       //! This method will remove duplicates.
00181       INT32 AppendDBList (
00182          INT32 ElemNum,
00183          const DBLIST& DBList
00184          );
00185 
00186       //! Append one list entry to this element.
00187       //! This method will remove duplicates.
00188       INT32 AppendDBList (
00189          INT32 ElemNum,
00190          const DBLISTELMT& item
00191          );
00192 
00193       //! Remove invalid entries from the element database attachment list
00194       ERRVALUE CleanDBList (
00195          );
00196 
00197       //! Compare attached element records from two databases to determine if the element attachmets are to the same records
00198       //! @return 'True' if they are, false if not.               
00199       bool CompareElementRecords (
00200          INT32 LhsElemNum,                         //!< Left side element number
00201          const DBASE_ELEMENT& rhs,                 //!< Other database to compare to
00202          INT32 RhsElemNum,                         //!< Right side element number
00203          const SIMPLE_ARRAY<INT32>& TableMatch     //!< Table translation array from Lhs database to Rhs database, See DBASE::FindTableMatches()
00204          ) const;
00205 
00206       //! Convert style assignment table from 'this' to 'DestDBaseObj' based on the 
00207       //! database object types
00208       ERRVALUE ConvertStyleAssignTableTo (
00209          DBASE_ELEMENT& DestDBaseObj               //!< Must be created outside this function and be open
00210          );
00211 
00212       //! Get the list of attached elements to a specific record        
00213       int GetAttachedElements (
00214          const RVC::DBTABLE::RECORD& record,       //!< Record to find attached elements of
00215          SIMPLE_ARRAY<INT32>& ElementList,
00216          ELEMTYPE ElemType = ELEMTYPE_Empty        //!< Defaults to DBASE_ELEMENT ElemType
00217          ) const;
00218 
00219       //! Get the list of attached elements to a specific record        
00220       int GetAttachedElements (
00221          const RVC::DBTABLE::RECORD& record,       //!< Record to find attached elements of
00222          SIMPLE_ARRAY<RVC::ELEMENT>& ElementList,
00223          ELEMTYPE ElemType = ELEMTYPE_Empty        //!< Defaults to DBASE_ELEMENT ElemType
00224          ) const;
00225 
00226       //! Get records attached to the specified element for all tables
00227       ERRVALUE GetAttachedRecordList (
00228          INT32 ElemNum,
00229          DBLIST& DBList,                     //!< List of attachments allocated and returned
00230          FINDFLAG FindFlag = FINDFLAG_AllAttached,
00231          INT32 BaseTableNum = -1
00232          ) const;
00233          
00234       //! Get the record numbers attached to the element for this table.
00235       //! @return Number of records attached or <0 if error 
00236       INT32 GetAttachedRecordNumbers (
00237          const RVC::ELEMENT& element,              //!< Element
00238          const RVC::DBTABLE& table,                //!< Table to get attached records for
00239          SIMPLE_ARRAY<INT32>& recordnums,          //!< Array of record numbers returned
00240          FINDFLAG findflags = FINDFLAG_AllAttached
00241          ) const;
00242 
00243       //! Get array of attachments to this element
00244       INT32 GetAttachments (
00245          const RVC::ELEMENT& elem,
00246          RVC::DBASE_ELEMENT::ATTACHMENTARRAY& items
00247          ) const;
00248 
00249       //! Get the size of an individual entries for an element database attachment list
00250       //! @return Number of items for an individual DBList entry
00251       INT32 GetDBListItemSize (
00252          INT32 ItemNum,
00253          bool ExcludeInternal = false
00254          ) const;
00255 
00256       //! Get the maximum number of entries for an element database attachment list
00257       //! @return Maximum number of DBList entries
00258       INT32 GetDBListMaxItemSize (
00259          ) const;
00260 
00261       //! Get the number of element database attachment list entries
00262       //! @return Number of DBList entries
00263       INT32 GetDBListNumElements (
00264          ) const;
00265 
00266       //! Get element type database is associated with.
00267       ELEMTYPE GetElemType (
00268          ) const { return (m_ElemType); }
00269 
00270       //! Determine if the given record has any elements attached
00271       //! @return 'True' if elements are attached, 'false' if not
00272       bool HasAttachedElements (
00273          const RVC::DBTABLE::RECORD& record,
00274          ELEMTYPE ElemType = ELEMTYPE_All
00275          ) const;
00276          
00277       //! Open the database.  If a database object does not exist, make one
00278       ERRVALUE OpenAsSubobject (
00279          const RVC::OBJITEM& ParentObjItem,           //!< Parent object to find and/or create database under
00280          OPENMODE mode = OPENMODE_Read,
00281          MDLGPARENT widget = 0               //!< Parent dialog handle, 0 for default handle
00282          );
00283 
00284       //! Open the database.  If a database object does not exist, make one
00285       ERRVALUE OpenAsSubobject (
00286          const RVC::GEOSPATIAL& parent,            //!< Parent object to find and/or create database under
00287          OPENMODE mode = OPENMODE_Read,
00288          MDLGPARENT widget = 0               //!< Parent dialog handle, 0 for default handle
00289          );
00290 
00291       //! Read an individual entry from the element database attachment list
00292       //! @return Number of entries read
00293       INT32 ReadDBList (
00294          INT32 ElemNum,
00295          DBLIST& DBList
00296          ) const;
00297 
00298       //! Remove the record attachment to the element
00299       ERRVALUE RemoveAttachment (
00300          const RVC::ELEMENT& elem,
00301          const RVC::DBASE_ELEMENT::ATTACHMENTITEM& item
00302          );
00303 
00304       //! Remove the array of record attachments to the element
00305       ERRVALUE RemoveAttachments (
00306          const RVC::ELEMENT& elem,
00307          const RVC::DBASE_ELEMENT::ATTACHMENTARRAY& items
00308          );
00309 
00310       //! Resize the number of entries in the element database attachment list
00311       ERRVALUE ResizeDBList (
00312          INT32 NumItems
00313          );
00314 
00315       //! Resize an individual entry from the element database attachment list
00316       ERRVALUE ResizeDBListItem (
00317          INT32 ElemNum,
00318          INT32 NumItems
00319          );
00320 
00321       //! Swap individual entries from the element database attachment list
00322       ERRVALUE SwapDBList (
00323          INT32 Item1,
00324          INT32 Item2
00325          );
00326 
00327       //! Write an individual entry from the element database attachment list
00328       //! @return Number of entries written
00329       INT32 WriteDBList (
00330          INT32 ElemNum,
00331          const DBLIST& DBList
00332          );
00333 
00334       //! Unattach items from an individual entry from the element database attachment list
00335       //! @return Number of entries unattached
00336       INT32 UnattachDBList (
00337          INT32 ElemNum,
00338          const DBLIST& DBList
00339          );
00340 
00341       //! Inform the database code that the number of elements has changed
00342       //! May not be needed
00343       ERRVALUE UpdateDBListNumElements (
00344          INT32 NumElements
00345          );
00346          
00347    private:
00348       #ifndef GENERATING_DOXYGEN_OUTPUT
00349 
00350       //! Implementation of RVC::OBJECT virtual methods
00351       virtual OBJTYPE v_GetDftObjectType () const;
00352       virtual bool v_IsMultiObject () const;
00353          
00354       ELEMTYPE m_ElemType;
00355       #endif // GENERATING_DOXYGEN_OUTPUT
00356 
00357    };
00358    
00359    
00360 class DBASE_ELEMENT::ATTACHMENTITEM {
00361    public:
00362 
00363       //! Default constructor.      
00364       ATTACHMENTITEM (
00365          ) : m_TableNum(TABLE_Invalid), m_RecordNum(RECORD_New) {}
00366       
00367       //! Construct from DBTABLE and record number.
00368       ATTACHMENTITEM (
00369          const RVC::DBTABLE& table,
00370          INT32 recordnum
00371          );
00372 
00373       //! Get the table number
00374       //! @return Table Number
00375       INT32 GetTableNum (
00376          ) const {return (m_TableNum);}
00377 
00378       //! Get the record number
00379       //! @return Record number
00380       INT32 GetRecordNum (
00381          ) const {return (m_RecordNum);}
00382 
00383       //! Set the table number
00384       void SetTableNum (
00385          INT32 TableNum
00386          ) {m_TableNum = TableNum;}
00387 
00388       //! Set the record number
00389       void SetRecordNum (
00390          INT32 RecordNum
00391          ) {m_RecordNum = RecordNum;}
00392 
00393    private:
00394       #ifndef GENERATING_DOXYGEN_OUTPUT
00395       
00396       INT32 m_TableNum;
00397       INT32 m_RecordNum;
00398       
00399       operator const DBLISTELMT* (
00400          ) const {return (reinterpret_cast<const DBLISTELMT*>(this));}
00401       
00402       operator DBLISTELMT* (
00403          ) {return (reinterpret_cast<DBLISTELMT*>(this));}
00404       
00405       friend class DBASE_ELEMENT;
00406       #endif // GENERATING_DOXYGEN_OUTPUT
00407    };
00408    
00409 //! Database object selection filter to select either a database object, which could be a subobject of a geospatial object.
00410 //! 
00411 class DBASE_ELEMENT::GETOBJFILTER_ISSELECTABLE : public RVC::GETOBJFILTER {
00412    public:
00413       // Default constructor.
00414       // If bCreateIfNotExist is true, navigating under a geospatial object
00415       // with this filter will force it to create the database subobjects
00416       // if they don't already exist.  You would normally only use this if
00417       // your filter is for the purposes of selecting an destination database.
00418       GETOBJFILTER_ISSELECTABLE (
00419          bool bCreateIfNotExist = false
00420          );
00421 
00422       // Constructor for a specific database subobject type.
00423       // If bCreateIfNotExist is true, navigating under a geospatial object
00424       // with this filter will force it to create the database subobjects
00425       // if they don't already exist.  You would normally only use this if
00426       // your filter is for the purposes of selecting an destination database.
00427       GETOBJFILTER_ISSELECTABLE (
00428          RVC::OBJTYPESET& type, 
00429          bool bCreateIfNotExist = false
00430          );
00431 
00432    private:
00433       #ifndef GENERATING_DOXYGEN_OUTPUT
00434       virtual bool v_HasSelectableSubObjects (const RVC::OBJITEM& objitem);
00435       virtual bool v_IsSelectable (const RVC::OBJITEM& objitem, int position);
00436       virtual bool v_IsValidParent (const RVC::OBJITEM& objitem);
00437       RVC::OBJTYPESET m_Types;
00438       bool m_bCreateIfNotExist;
00439       #endif // GENERATING_DOXYGEN_OUTPUT
00440    }; 
00441    
00442 
00443 
00444 }     //! End of RVC namespace
00445 
00446 #endif   //!< INC_RVC_DBELEM_H

Generated on Wed May 31 15:27:18 2006 for TNTsdk by  doxygen 1.3.8-20040913