list.h

Go to the documentation of this file.
00001 /**
00002  * \file rvc/list.h 
00003  * \brief interface for the RVC::LIST class.
00004  *
00005  * \if NODOC
00006  * $Id: list.h_v 1.9 2004/02/26 21:53:17 scowan Exp $
00007  *
00008  * $Log: list.h_v $
00009  * Revision 1.9  2004/02/26 21:53:17  scowan
00010  * Fixed compiler warning.
00011  *
00012  * Revision 1.8  2003/10/07 17:32:23  scowan
00013  * Object virtual method changes.
00014  *
00015  * Revision 1.7  2003/09/30 16:52:06  dwilliss
00016  * Doxygen
00017  *
00018  * Revision 1.6  2003/09/25 21:20:04  dwilliss
00019  * Fixed doxygen comment
00020  *
00021  * Revision 1.5  2003/09/15 13:49:45  fileserver!dwilliss
00022  * Doxygen
00023  *
00024  * Revision 1.4  2003/08/27 21:27:06  scowan
00025  * Uses new rvc list class interface and handle.
00026  *
00027  * Revision 1.3  2003/04/09 21:24:45  dwilliss
00028  * Don't use _T in templates.  Mac's ctype.h defines a global _T
00029  *
00030  * Revision 1.2  2001/06/14 19:09:50  scowan
00031  * Added to RVC namespace.
00032  *
00033  * Revision 1.1  2001/05/24 16:11:59  scowan
00034  * Initial revision
00035  *
00036  * \endif
00037 **/
00038 
00039 //!   \class RVC::LIST rvc/list.h
00040 //!   \brief Manages RVC::OBJTYPE_GenericRef objects.  
00041 //!   
00042 //!   The interface currently wraps the MfList functions.
00043 //!   
00044 //!   RVC Object Types that this class supports: RVC::OBJTYPE_GenericRef.
00045 //!
00046 //!   Default RVC Object Type for this class: RVC::OBJTYPE_GenericRef.
00047 //!
00048 //!   Valid parents for this class:
00049 //!      - RVC::OBJTYPE_File
00050 //!      - RVC::OBJTYPE_Folder
00051 
00052 #ifndef INC_RVC_LIST_H
00053 #define INC_RVC_LIST_H
00054 
00055 #ifndef INC_RVC_OBJECT_H
00056    #include <rvc/object.h>
00057 #endif
00058 
00059 #ifndef INC_MI32_SIMPLEAR_H
00060    #include <mi32/simplear.h>
00061 #endif
00062 
00063 #ifndef GENERATING_DOXYGEN_OUTPUT
00064 struct RVCGENLISTINFO;     // Forward declarations
00065 #endif // GENERATING_DOXYGEN_OUTPUT
00066 
00067 namespace RVC {
00068 
00069 #ifndef GENERATING_DOXYGEN_OUTPUT
00070 class LISTHANDLE;    // Forward declarations
00071 #endif // GENERATING_DOXYGEN_OUTPUT
00072 
00073 class LIST : public RVC::OBJECT {
00074    public:
00075 
00076       //! Default constructor
00077       LIST (
00078          );
00079 
00080       //! Copy constructor
00081       LIST (
00082          const RVC::LIST& obj
00083          );
00084 
00085       //! Destructor
00086       virtual ~LIST (
00087          );
00088 
00089       //! Assignment.  Will close if necessary and reopen if 'rhs' is open
00090       RVC::LIST& operator= (
00091          const RVC::LIST& rhs
00092          );
00093 
00094       //! Obtain the size of a list entry
00095       //! @return List entry size   
00096       INT32 GetItemSize (
00097          INT32 ItemNum
00098          ) const;
00099          
00100       //! Obtain the size of the largest list entry
00101       //! @return Largest list entry size 
00102       INT32 GetMaxItemSize (
00103          ) const;
00104          
00105       //! Obtain the number of list entries
00106       //! @return Number of list entries
00107       INT32 GetNumItems (
00108          ) const;
00109       
00110       //! Inserts 1 or more entries into a generic list with each new entry initially the size of zero
00111       ERRVALUE InsertItems (
00112          INT32 StartPosn,
00113          INT32 NumItems = 1
00114          );
00115 
00116       //! Create a new rvc list object under a specified parent rvc object with name, description, and source
00117       ERRVALUE Make (
00118          const RVC::OBJECT& parent,       //!< Parent object to create list object under
00119          const RVC::OBJECTNAME& name,        //!< Name of new list object
00120          const RVC::OBJECTDESC& desc,        //!< Description of new list object
00121          const char* Source = 0           //!< Source of new list object, default is application name
00122          );
00123 
00124       //! Create a new rvc list object under a specified parent rvc object with name, description, and source
00125       ERRVALUE Make (
00126          const RVC::OBJITEM& ObjItem,
00127          const char* Source = 0           //!< Source of new list object, default is application name
00128          );
00129 
00130       //! Read a list entry
00131       //! @return Number of bytes of the entry     
00132       INT32 Read (
00133          INT32 ItemNum,
00134          void *ptr
00135          ) const;
00136 
00137       //! Read a list entry
00138       //! @return Number of bytes of the entry     
00139       INT32 Read (
00140          INT32 ItemNum,
00141          void **buffer,
00142          INT32 BufferSize
00143          ) const;
00144 
00145       //! Read a list entry into a SIMPLE_ARRAY
00146       template <class _CT>
00147       ERRVALUE Read (
00148          INT32 ItemNum,
00149          SIMPLE_ARRAY<_CT>& data
00150          ) const {
00151          INT32 MaxItems = data.GetMaxItems();
00152          _CT* buffer = data.Detach();
00153          INT32 NumBytes = Read(ItemNum, reinterpret_cast<void**>(&buffer), MaxItems * sizeof(_CT));
00154          if (NumBytes < 0) {
00155             data.Attach(buffer, MaxItems);
00156             data.Clear();
00157             }
00158          else {
00159             if (static_cast<UINT32>(NumBytes) > MaxItems * sizeof(_CT)) MaxItems = NumBytes / sizeof(_CT);
00160             data.Attach(buffer, MaxItems);
00161             data.Resize(NumBytes / sizeof(_CT), true, false);  //! Set to correct number of items
00162             NumBytes = 0;
00163             }
00164          return (NumBytes);
00165          }
00166          
00167       //! Partially read a list entry
00168       //! @return Number of bytes read of the entry      
00169       INT32 Read (
00170          INT32 ItemNum,
00171          INT32 StartPosn,
00172          INT32 Length,
00173          void *ptr
00174          ) const;
00175 
00176       //! Read a list entry into a SIMPLE_ARRAY
00177       template <class _CT>
00178       ERRVALUE Read (
00179          INT32 ItemNum,
00180          INT32 StartPosn,
00181          INT32 Length,        //!< Length in _CT units
00182          SIMPLE_ARRAY<_CT>& data
00183          ) const {
00184          INT32 NumBytes = ReadPartial(ItemNum, StartPosn * sizeof(_CT), Length * sizeof(_CT), static_cast<void*>(data));
00185          if (NumBytes >= 0) {
00186             data.Resize(NumBytes / sizeof(_CT), true, false);  //! Set to correct number of items
00187             NumBytes = 0;
00188             }
00189          return (NumBytes);
00190          }
00191          
00192       //! Resize the list to a new number of items
00193       ERRVALUE Resize (
00194          INT32 NewNumItems
00195          );
00196 
00197       //! Resize a list item to a new size      
00198       ERRVALUE ResizeItem (
00199          INT32 ItemNum,
00200          INT32 NewItemSize
00201          );
00202          
00203       //! Swap two list items
00204       ERRVALUE SwapItems (
00205          INT32 Item1,
00206          INT32 Item2
00207          );
00208          
00209       //! Write data to a list item
00210       //! @return Number of bytes written
00211       INT32 Write (
00212          INT32 ItemNum,
00213          INT32 Length,
00214          const void* ptr
00215          );
00216          
00217       //! Write partial data to a list item
00218       //! @return Number of bytes written
00219       INT32 Write (
00220          INT32 ItemNum,
00221          INT32 TotalSize,
00222          INT32 StartPosn,
00223          INT32 Length,
00224          const void* ptr
00225          );
00226          
00227       //! Write SIMPLE_ARRAY<> to a list item
00228       template <class _CT>
00229       ERRVALUE Write (
00230          INT32 ItemNum,
00231          const SIMPLE_ARRAY<_CT>& data
00232          ) {
00233          ERRVALUE err = Write(ItemNum, data.GetNumItems() * sizeof(_CT), data);
00234          if (err > 0) err = 0;
00235          return (err);
00236          }
00237          
00238    protected:     
00239       
00240       //! Used for objects that inherit from this object
00241       ERRVALUE Make (const OBJECT& parent, const OBJECTNAME& name, const OBJECTDESC& desc, RVCGENLISTINFO& newinfo, int HeaderSize, int HeaderType, const char* Source);
00242 
00243       //! Used for objects that inherit from this object
00244       ERRVALUE OpenObject (OPENMODE OpenFlags, RVCGENLISTINFO& newinfo, int HeaderSize, int HeaderType, MDLGPARENT parent);
00245       
00246    private:
00247       #ifndef GENERATING_DOXYGEN_OUTPUT
00248 
00249       //! Implementation of RVC::OBJECT virtual methods
00250       virtual ERRVALUE v_CloseObject ();           //! Close the open object
00251       virtual OBJTYPE v_GetDftObjectType () const;    //!< Get the default object type
00252       virtual bool v_IsObjectOpen () const;              //!< Is this object opened?
00253       virtual ERRVALUE v_OpenObject (OPENMODE OpenFlags, MDLGPARENT parent);           //! Open the object
00254 
00255       LISTHANDLE* m_ListHandle;
00256       #endif // GENERATING_DOXYGEN_OUTPUT
00257    };
00258 
00259 }     //! End of RVC namespace
00260 
00261 #endif   //!< INC_RVC_LIST_H

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