objitem.h

Go to the documentation of this file.
00001 /**
00002  * \file rvc/objitem.h
00003  * \brief RVC::OBJITEM class definitions
00004  *
00005  * $Id: objitem.h_v 1.1 2004/07/22 14:31:00 mju Exp $
00006  *
00007  * $Log: objitem.h_v $
00008  * Revision 1.1  2004/07/22 14:31:00  mju
00009  * Initial revision
00010  *
00011 **/
00012 
00013 #ifndef  INC_RVC_OBJITEM_H
00014 #define  INC_RVC_OBJITEM_H
00015 
00016 #ifndef  INC_MI32_RVCDEFNS_H
00017 #include <mi32/rvcdefns.h>
00018 #endif
00019 
00020 namespace RVC {
00021 
00022 //=====================================================================================================================
00023 
00024 //! OBJITEM class for specifying a particular file and object.
00025 class OBJITEM {
00026    public:
00027 
00028       //! Setup output object item list corresponding to specified input object item list.
00029       static void SetupOutputList (
00030          MILIST<OBJITEM>& oobjlist,          //!< Output list
00031          const MILIST<OBJITEM>& iobjlist,    //!< Input list
00032          const char *source = 0              //!< Value to use for "source" in object header, will use application name if null.
00033          );
00034 
00035       //! Default constructor.
00036       OBJITEM (
00037          ) {
00038          m_ginfo.objectinode = -1;        // Set to nothing
00039          }
00040 
00041       //! Copy constructor.
00042       OBJITEM (
00043          const OBJITEM& rhs               //!< Object to copy from
00044          ) : m_filename(rhs.m_filename), m_ginfo(rhs.m_ginfo), m_ObjectPath(rhs.m_ObjectPath) {}
00045 
00046       //! Construct from FILEPATH and RVCGENINFO.
00047       OBJITEM (
00048          const FILEPATH& filename,        //!< Filename
00049          const RVCGENINFO& ginfo          //!< General info
00050          ) : m_filename(filename), m_ginfo(ginfo) {}
00051 
00052       //! Construct from FILEPATH and object path string.
00053       OBJITEM (
00054          const FILEPATH& filename,        //!< Filename
00055          const MISTRING& ObjectPath       //!< Object path
00056          ) : 
00057          m_filename(filename), 
00058          m_ObjectPath(ObjectPath)
00059          {
00060          m_ginfo.objectinode = -1;        // Set to nothing
00061          }
00062 
00063       //! Construct from FILEPATH and object inode.
00064       OBJITEM (
00065          const FILEPATH& filename,        //!< Filename
00066          RVCINODENUM inode                //!< Object inode
00067          ) { SetItem(filename,inode); }
00068 
00069       //! Construct having specified name, description, optional source.
00070       //! This useful when setting up an "output" OBJITEMLIST.
00071       OBJITEM (
00072          const MISTRING& name,
00073          const MISTRING& desc,
00074          const char *source = 0
00075          );
00076 
00077       //! Assignment.
00078       OBJITEM operator= (
00079          const OBJITEM& rhs               //!< Object to copy from
00080          ) {
00081          if (this != &rhs) {
00082             m_filename = rhs.m_filename;
00083             m_ginfo = rhs.m_ginfo;
00084             m_ObjectPath = rhs.m_ObjectPath;
00085             }
00086          return (*this);
00087          }
00088          
00089       //! Clear the OBJITEM, refers to nothing
00090       void Clear (
00091          ) {
00092          m_ginfo.Clear();
00093          m_ginfo.objectinode = -1;        // Set to nothing
00094          m_filename.Clear();
00095          m_ObjectPath.Clear();
00096          }
00097 
00098       //! Get string suitable for display.
00099       //! String will consist of file name, separator and object name.
00100       //! @seealso GetToolTipString
00101       void GetDisplayString (
00102          MISTRING& string                    //!< String returned
00103          ) const;
00104 
00105       //! Get the filepath.
00106       const FILEPATH& GetFilePath (
00107          ) const {
00108          return (m_filename);
00109          }
00110 
00111       //! Get the inode.
00112       RVCINODENUM GetInode (
00113          ) const {
00114          if (m_ginfo.objectinode == -1) ResolveObjectPath();
00115          return (m_ginfo.objectinode);
00116          }
00117 
00118       //! Get info.
00119       const RVCGENINFO& GetInfo (
00120          ) const {
00121          if (m_ginfo.objectinode == -1) ResolveObjectPath();
00122          return (m_ginfo);
00123          }
00124 
00125       //! Get object description.
00126       const RVC::OBJECTDESC& GetObjectDescription (
00127          ) const {
00128          if (m_ginfo.objectinode == -1) ResolveObjectPath();
00129          return (m_ginfo.desc);
00130          }
00131 
00132       //! Get object name.
00133       const RVC::OBJECTNAME& GetObjectName (
00134          ) const {
00135          if (m_ginfo.objectinode == -1) ResolveObjectPath();
00136          return (m_ginfo.name);
00137          }
00138 
00139       //! Get the Object Path
00140       ERRVALUE GetObjectPath (
00141          MISTRING& ObjectPath
00142          ) const {
00143          if (m_ginfo.objectinode == -1) {
00144             ObjectPath = m_ObjectPath;
00145             return (0);
00146             }
00147          return (DetermineObjectPath(ObjectPath));
00148          }
00149 
00150       //! Get the object type.
00151       RVC::OBJTYPE GetObjectType (
00152          ) const {
00153          return (static_cast<RVC::OBJTYPE>((m_ginfo.objectinode == -1) ? QuickObjectType() : m_ginfo.objtype));
00154          }
00155 
00156       //! Get standard "ToolTip" string for this item.
00157       //! @seealso GetDisplayString.
00158       void GetToolTipString (
00159          MISTRING& string                 //!< Tooltip string returned
00160          ) const;
00161 
00162       //! Determine if have both filepath and "object" assigned.
00163       //! Does not determine if actually resolved to existing object.
00164       bool IsAssigned (
00165          ) const {
00166          return (!m_filename.IsEmpty() && (IsResolved() || !m_ObjectPath.IsEmpty()));
00167          }
00168 
00169       //! Is it the same?
00170       bool IsEqual (
00171          const OBJITEM& rhs            //!< Object to compare
00172          ) const {
00173          if (m_ginfo.objectinode == -1) ResolveObjectPath();
00174          return (m_filename == rhs.m_filename && m_ginfo.objectinode == rhs.m_ginfo.objectinode);
00175          }
00176 
00177       //! Determine if item references actual existing object.
00178       //! This should not be used in time-critical operations as it will actually
00179       //! open the file and verify that the object exists.
00180       bool IsExisting (
00181          ) const;
00182 
00183       //! Determine if has been resolved to specific existing object.
00184       bool IsResolved (
00185          ) const { return (m_ginfo.objectinode >= 0); }
00186          
00187       //! Set filename
00188       void SetFilePath (
00189          const FILEPATH& filepath
00190          ) { m_filename = filepath; }
00191 
00192       //! Set item from FILEPATH and RVCGENINFO.
00193       void SetItem (
00194          const FILEPATH& filename,        //!< File name
00195          const RVCGENINFO& ginfo          //!< General info
00196          ) {
00197          m_filename = filename;
00198          m_ginfo = ginfo;
00199          m_ObjectPath.Clear();
00200          }
00201 
00202       //! Set item from FILEPATH and object path.
00203       void SetItem (
00204          const FILEPATH& filename,        //!< File name
00205          const MISTRING& ObjectPath       //!< Object path
00206          ) {
00207          m_filename = filename;
00208          m_ginfo.Clear();
00209          m_ginfo.objectinode = -1;
00210          m_ObjectPath = ObjectPath;
00211          }
00212 
00213       //! Set item from FILEPATH and object inode.
00214       void SetItem (
00215          const FILEPATH& filename,        //!< File name
00216          RVCINODENUM inode                //!< Object inode
00217          );
00218 
00219       //! Setup for use in prompt for or creation of new object with RVC::OBJECT parent.
00220       void SetNew (
00221          const RVC::OBJECT& ParentObj,       //!< Parent object reference
00222          RVC::OBJTYPE ObjType,               //!< New object type
00223          const RVC::OBJECTNAME& Name,        //!< New object name
00224          const RVC::OBJECTDESC& Description, //!< New object description
00225          const char *Source = 0
00226          );
00227 
00228       //! Setup for use in prompt for or creation of new object with RVC::OBJECT parent.
00229       //! @deprecated, Use variant with OBJECTNAME, OBJECTDESC parameters.
00230       DEPRECATED void SetNew (
00231          const RVC::OBJECT& ParentObj,    //!< Parent object reference
00232          RVC::OBJTYPE ObjType,            //!< New object type
00233          const UNICODE *Name,             //!< New object name
00234          const UNICODE *Description,      //!< New object description
00235          const UNICODE *Source = 0
00236          );
00237 
00238       //! Setup for use in prompt for or creation of new object with RVC::OBJITEM parent.
00239       void SetNew (
00240          const RVC::OBJITEM& ParentItem,     //!< Parent object item reference
00241          RVC::OBJTYPE ObjType,               //!< New object type
00242          const RVC::OBJECTNAME& Name,        //!< New object name
00243          const RVC::OBJECTDESC& Description, //!< New object description
00244          const char *Source = 0
00245          );
00246 
00247       //! Setup for use in prompt for or creation of new object with RVC::OBJITEM parent.
00248       //! @deprecated, Use variant with OBJECTNAME, OBJECTDESC parameters.
00249       DEPRECATED void SetNew (
00250          const RVC::OBJITEM& ParentItem,  //!< Parent object item reference
00251          RVC::OBJTYPE ObjType,            //!< New object type
00252          const UNICODE *Name,             //!< New object name
00253          const UNICODE *Description,      //!< New object description
00254          const UNICODE *Source = 0
00255          );
00256 
00257       //! Set object description from RVC::OBJECTDESC.
00258       void SetObjectDescription (
00259          const RVC::OBJECTDESC& NewDesc
00260          ) { m_ginfo.desc = NewDesc; }
00261 
00262       //! Set object info from RVCGENINFO.
00263       void SetObjectInfo (
00264          const RVCGENINFO& ginfo          //!< General info
00265          ) {
00266          m_ginfo = ginfo;
00267          m_ObjectPath.Clear();
00268          }
00269 
00270       //! Set object name from RVC::OBJECTNAME.
00271       void SetObjectName (
00272          const RVC::OBJECTNAME& NewName
00273          ) { m_ginfo.name = NewName; }
00274 
00275       //! Set object path without clearing file path.
00276       void SetObjectPath (
00277          const MISTRING& ObjectPath       //!< Object path
00278          ) {
00279          m_ginfo.Clear();
00280          m_ginfo.objectinode = -1;
00281          m_ObjectPath = ObjectPath;
00282          }
00283 
00284       //! Set object type if not bound to an object.
00285       void SetObjectType (
00286          UINT32 objtype                   //!< Object type
00287          ) { if (m_ginfo.objectinode < 0) m_ginfo.objtype = objtype; }
00288 
00289    private:
00290       #ifndef GENERATING_DOXYGEN_OUTPUT
00291 
00292       FILEPATH m_filename;                //!< File name
00293       mutable RVCGENINFO m_ginfo;         //!< General info
00294       MISTRING m_ObjectPath;              //!< Object path
00295 
00296       //! Determine object path from m_ginfo.
00297       ERRVALUE DetermineObjectPath (
00298          MISTRING& ObjectPath             //!< Object path returned
00299          ) const;
00300 
00301       //! Determine object type.
00302       UINT32 QuickObjectType (
00303          ) const;
00304          
00305       //! Resolve object path and setup m_ginfo.
00306       void ResolveObjectPath (
00307          ) const;
00308       #endif // GENERATING_DOXYGEN_OUTPUT
00309    };
00310 
00311 typedef MILIST<OBJITEM> OBJITEMLIST;
00312 
00313 //! Equality operator.
00314 inline bool operator== (
00315    const RVC::OBJITEM& lhs,            //!< Object to compare
00316    const RVC::OBJITEM& rhs             //!< Object to compare
00317    ) {
00318    return (lhs.IsEqual(rhs));
00319    }
00320 
00321 //! Inequality operator.
00322 inline bool operator!= (
00323    const RVC::OBJITEM& lhs,            //!< Object to compare
00324    const RVC::OBJITEM& rhs             //!< Object to compare
00325    ) {
00326    return (!lhs.IsEqual(rhs));
00327    }
00328 
00329 //=====================================================================================================================
00330 
00331 }     //! End of RVC namespace
00332 
00333 
00334 //! Pre-namespace typedefs.
00335 typedef RVC::OBJITEM RVCOBJITEM;
00336 typedef RVC::OBJITEMLIST RVCOBJITEMLIST;
00337 
00338 
00339 #endif   // INC_RVC_OBJITEM_H

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