Main Page | Class List | File List | Class Members

CS_ELEMENT.hpp

00001 
00002 #include<string>
00003 #include<iostream>
00004 #include<sstream>
00005 
00006 #include "CACHE.hpp"
00007 
00008 #ifndef _H_CS_ELEMENT
00009 #define _H_CS_ELEMENT
00010 
00012 template < typename T > class CS_ELEMENT {
00013    private:
00014 
00015    protected:
00016 
00018         T* _array;
00019 
00021         unsigned long int FAC;
00022 
00023    public:
00024 
00025         //static stuff first
00026 
00027         //end static stuff
00028 
00030         CS_ELEMENT() {
00031                 _array = new T[ 1 ];
00032                 FAC    = 0;
00033         }
00034 
00036         CS_ELEMENT( const T initial_caption ) {
00037                 _array = new T[ 1 ];
00038                 FAC    = 0;
00039                 access() = initial_caption;
00040         }
00041 
00043         ~CS_ELEMENT() {
00044                 delete [] _array;
00045         }
00046 
00048         const T& const_access() {
00049                 CACHE::getInstance()->access( &( _array[ 0 ] ), sizeof( T ), FAC );
00050                 return _array[ 0 ];
00051         }
00052 
00054         T& access() {
00055                 CACHE::getInstance()->access( &( _array[ 0 ] ), sizeof( T ), FAC );
00056                 return _array[ 0 ];
00057         }
00058 
00060         T& unrecorded_access() { return _array[ 0 ]; }
00061 
00063         const T& unrecorded_const_access() const { return _array[ 0 ]; }
00064 
00065         //operator overloading:
00066         CS_ELEMENT< T >& operator=( const CS_ELEMENT< T >& other ) { access() = other.const_access(); return *this; }
00067         CS_ELEMENT< T >& operator=( const T& other ) { access() = other; return *this; }
00068         CS_ELEMENT< T > operator+( const CS_ELEMENT< T >& other ) const { return CS_ELEMENT< T >( const_access() + other.const_access() ); }
00069         CS_ELEMENT< T > operator-( const CS_ELEMENT< T >& other ) const { return CS_ELEMENT< T >( const_access() - other.const_access() ); }
00070         CS_ELEMENT< T > operator*( const CS_ELEMENT< T >& other ) const { return CS_ELEMENT< T >( const_access() * other.const_access() ); }
00071         CS_ELEMENT< T > operator/( const CS_ELEMENT< T >& other ) const { return CS_ELEMENT< T >( const_access() / other.const_access() ); }
00072 
00073         void operator++() { ++( access() ); }
00074 
00075         //comparators:
00076         bool operator<( const T& other ) const { return const_access() < other; }
00077         bool operator<( const CS_ELEMENT< T >& other ) const { return const_access() < other.const_access(); }
00078         bool operator>( const T& other ) const { return const_access() > other; }
00079         bool operator>( const CS_ELEMENT< T >& other ) const { return const_access() > other.const_access(); }
00080         bool operator==( const T& other ) const { return const_access() == other; }
00081         bool operator==( const CS_ELEMENT< T >& other ) const { return const_access() == other.const_access(); }
00082         
00083 };
00084 
00085 #endif
00086 

Generated on Fri Aug 15 18:12:22 2008 for Run-timeCacheSimulator by  doxygen 1.3.9.1