00001 00002 00003 00004 00005 00006 00007 00008 00009 00010 00011 00012 00013 00014 00015 00016 00017 00018 00019 00020 00021 00022 00023 00024 00025 00026 00027 00028 00029 #ifndef __SEAL_COORD_H__ 00030 #define __SEAL_COORD_H__ 00031 00032 #include "exception.h" 00033 #include "randaccess.h" 00034 00035 namespace seal 00036 { 00037 00040 template <unsigned int dimension> 00041 class Coordinate : public RandomAccess<unsigned int> 00042 { 00043 public: 00046 Coordinate(void) {} 00047 00050 Coordinate(const Coordinate<dimension> &c); 00051 00054 virtual ~Coordinate() {} 00055 00059 unsigned int& operator[](const int index) throw(OutOfRangeException<int>); 00060 00064 const unsigned int& operator[](const int index) const throw(OutOfRangeException<int>); 00065 00066 private: 00067 unsigned int data[dimension]; 00068 }; 00069 00070 template <unsigned int dimension> 00071 Coordinate<dimension>::Coordinate(const Coordinate<dimension> &c) 00072 { 00073 for (int i = 0; i < dimension; i++) 00074 data[i] = c.data[i]; 00075 } 00076 00077 template <unsigned int dimension> 00078 unsigned int& Coordinate<dimension>::operator[](const int index) throw(OutOfRangeException<int>) 00079 { 00080 if (index >= dimension || index < 0) 00081 throw OutOfRangeException<int>(0, dimension-1, index); 00082 00083 return data[index]; 00084 } 00085 00086 template <unsigned int dimension> 00087 const unsigned int& Coordinate<dimension>::operator[](const int index) const throw(OutOfRangeException<int>) 00088 { 00089 if (index >= dimension || index < 0) 00090 throw OutOfRangeException<int>(0, dimension-1, index); 00091 00092 return data[index]; 00093 } 00094 00095 } // End of namespace seal 00096 00097 #endif // __SEAL_COORD_H__ 00098