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

Generated on Tue Dec 14 13:18:45 2004 for TNTsdk by  doxygen 1.3.8-20040913