element.h

Go to the documentation of this file.
00001 /**
00002  * \file rvc/element.h
00003  * \brief interface for the RVC::ELEMDBASE class.
00004  *
00005  * \if NODOC
00006  * $Id: element.h_v 1.9 2004/07/22 15:27:26 dwilliss Exp $
00007  *
00008  * $Log: element.h_v $
00009  * Revision 1.9  2004/07/22 15:27:26  dwilliss
00010  * Added an operator< so I could use RVC::ELEMENT as a key in std::map
00011  *
00012  * Revision 1.8  2004/04/14 19:21:44  dwilliss
00013  * Added a couple #includes so it would compile in isolation
00014  *
00015  * Revision 1.7  2004/03/22 16:15:58  scowan
00016  * Added clear method.
00017  *
00018  * Revision 1.6  2003/09/25 21:56:37  dwilliss
00019  * doxygen
00020  *
00021  * Revision 1.5  2003/09/15 13:49:45  fileserver!dwilliss
00022  * Doxygen
00023  *
00024  * Revision 1.4  2002/04/19 16:43:02  mju
00025  * Make ctor from elemnum explicit.
00026  *
00027  * Revision 1.3  2002/04/11 19:48:41  mju
00028  * Forgot to inline non-member operators.
00029  *
00030  * Revision 1.2  2002/04/11 17:56:46  mju
00031  * Add comparison operators.
00032  *
00033  * Revision 1.1  2002/04/11 17:46:11  scowan
00034  * Initial revision
00035  * \endif
00036 **/
00037  
00038 #ifndef INC_RVC_ELEMENT_H
00039 #define INC_RVC_ELEMENT_H
00040 
00041 #ifndef INC_MI32_STDDEFNS_H
00042 #include <mi32/stddefns.h>
00043 #endif
00044 
00045 #ifndef INC_MI32_ELEMTYPE_H
00046 #include <mi32/elemtype.h>
00047 #endif
00048 
00049 
00050 namespace RVC {
00051 
00052 //! Container for spatial element specifying type and number.
00053 class ELEMENT {
00054    public:
00055 
00056       //! Default constructor.   
00057       ELEMENT (
00058          ) : m_ElemNum(-1), m_ElemType(ELEMTYPE_Empty) {}
00059 
00060       //! Construct from element number.
00061       explicit ELEMENT (
00062          INT32 ElemNum
00063          ) : m_ElemNum(ElemNum), m_ElemType(ELEMTYPE_Empty) {}
00064 
00065       //! Construct from element number and type.
00066       ELEMENT (
00067          INT32 ElemNum,
00068          ELEMTYPE ElemType
00069          ) : m_ElemNum(ElemNum), m_ElemType(ElemType) {}
00070 
00071       //! Copy construct from ELEMENT and fallback element type.
00072       ELEMENT (
00073          const ELEMENT& elem,                //!< Element to copy
00074          ELEMTYPE ElemType                   //!< Fallback element type, used if not set in 'elem'
00075          ) : m_ElemNum(elem.m_ElemNum), m_ElemType((elem.m_ElemType == ELEMTYPE_Empty) ? ElemType : elem.m_ElemType) {}
00076 
00077       //! Clear to element info back to no element       
00078       void Clear (
00079          ) { 
00080          m_ElemNum = -1; 
00081          m_ElemType = ELEMTYPE_Empty; 
00082          }
00083 
00084       //! Get the stored element number.
00085       //! @return Element number
00086       INT32 GetNumber (
00087          ) const { return (m_ElemNum); }
00088          
00089       //! Get the stored ELEMTYPE.
00090       //! @return ELEMTYPE       
00091       ELEMTYPE GetType (
00092          ) const { return (m_ElemType); }
00093 
00094       //! Set the element number.
00095       void SetNumber (
00096          INT32 ElemNum
00097          ) { m_ElemNum = ElemNum; }
00098 
00099       //! Set the element type (ELEMTYPE).         
00100       void SetType (
00101          ELEMTYPE ElemType
00102          ) { m_ElemType = ElemType; }
00103          
00104    private:
00105       #ifndef GENERATING_DOXYGEN_OUTPUT
00106       INT32 m_ElemNum;
00107       ELEMTYPE m_ElemType;
00108       #endif // GENERATING_DOXYGEN_OUTPUT
00109       
00110    };
00111 
00112 //! Compare ELEMENTs for equality.
00113 inline bool operator== (
00114    const ELEMENT& lhs,
00115    const ELEMENT& rhs
00116    ) { return (lhs.GetNumber() == rhs.GetNumber() && lhs.GetType() == rhs.GetType()); }
00117    
00118 //! Compare ELEMENTs for inequality.
00119 inline bool operator!= (
00120    const ELEMENT& lhs,
00121    const ELEMENT& rhs
00122    ) { return (!operator==(lhs,rhs)); }
00123    
00124 //! Compare ELEMENTs for ordering.
00125 //! Elements are sorted by type then by element number.
00126 //! This comparison it to allow RVC::ELEMENT to be used as a Key in std::map
00127 inline bool operator< (
00128    const ELEMENT& lhs,
00129    const ELEMENT& rhs
00130    ) {
00131    if (lhs.GetType() == rhs.GetType()) return (lhs.GetNumber() < rhs.GetNumber());
00132    return (static_cast<int>(lhs.GetType()) < static_cast<int>(rhs.GetType()));
00133    }
00134    
00135 }     //! End of RVC namespace
00136 
00137 #endif   //!< INC_RVC_ELEMENT_H
00138 

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