Main   Namespaces   Classes   Hierarchy   Annotated   Files   Compound   Global   Pages  

VCMiai.hpp

Go to the documentation of this file.
00001 //----------------------------------------------------------------------------
00002 /** @file VCMiai.hpp
00003  */
00004 //----------------------------------------------------------------------------
00005 
00006 #ifndef VCMIAI_HPP
00007 #define VCMIAI_HPP
00008 
00009 #include "Hex.hpp"
00010 
00011 _BEGIN_BENZENE_NAMESPACE_
00012 
00013 //----------------------------------------------------------------------------
00014 
00015 typedef unsigned short VCMiai;
00016 
00017 static const VCMiai NO_MIAI = FIRST_INVALID * FIRST_INVALID;
00018 
00019 namespace VCMiaiUtil
00020 {
00021     VCMiai Get(HexPoint x, HexPoint y);
00022 
00023     HexPoint First(const VCMiai& miai);
00024 
00025     HexPoint Second(const VCMiai& miai);
00026 }
00027 
00028 inline VCMiai Get(HexPoint x, HexPoint y)
00029 {
00030     return x * FIRST_INVALID + y;
00031 }
00032 
00033 inline HexPoint First(const VCMiai& miai)
00034 {
00035     return static_cast<HexPoint>(miai / FIRST_INVALID);
00036 }
00037 
00038 inline HexPoint Second(const VCMiai& miai)
00039 {
00040     return static_cast<HexPoint>(miai % FIRST_INVALID);
00041 }
00042 
00043 //----------------------------------------------------------------------------
00044 
00045 #define NUM_MIAI 4
00046 
00047 class VCMiaiList
00048 {
00049 public:
00050     VCMiaiList();
00051 
00052     VCMiai operator[](int index) const;
00053 
00054 private:
00055     VCMiai m_miai[NUM_MIAI];
00056 };
00057 
00058 inline VCMiaiList::VCMiaiList()
00059 {
00060     for (int i = 0; i < NUM_MIAI; ++i)
00061         m_miai[i] = NO_MIAI;
00062 }
00063 
00064 inline VCMiai VCMiaiList::operator[](int index) const
00065 {
00066     if (index < 0 || index >= NUM_MIAI)
00067         return NO_MIAI;
00068     return m_miai[index];
00069 }
00070 
00071 //----------------------------------------------------------------------------
00072 
00073 _END_BENZENE_NAMESPACE_
00074 
00075 #endif  // VCMIAI_HPP
00076  


6 Jan 2011 Doxygen 1.6.3