Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members  

ModuleId.h

Go to the documentation of this file.
00001 // $Id: ModuleId.h,v 1.4 2001/03/20 21:41:03 burnett Exp $
00002 
00003 #ifndef GLAST_MODULEID_H
00004 #define GLAST_MODULEID_H 1
00005 
00011 namespace idents {
00012 
00013 class ModuleId
00014 {
00015   public:
00016 
00017       enum {xNum=4, yNum=4}; // not likely to change again
00018 
00020       ModuleId (unsigned int id = 0):m_id(id){}
00021 
00023       ModuleId (unsigned int ix, unsigned int iy):m_id(ix-1+xNum*(iy-1)){}
00024 
00026       int ix () const {return (m_id % xNum)+1;}
00027 
00029       int iy () const {return (m_id / xNum)+1;}
00030 
00032       bool neighbor (const ModuleId& n){
00033           int dx = ix()-n.ix(), dy=iy()-n.iy();
00034           return dx<2 && dx>-2 && dy<2 && dy>-2; 
00035       }
00036 
00038       operator unsigned int () const { return m_id; }
00039 
00040 private:
00041       unsigned int m_id;
00042 };
00043 
00044 } //namespace idents
00045 #endif

Generated at Wed Nov 21 12:20:09 2001 by doxygen1.2.3 written by Dimitri van Heesch, © 1997-2000