LAMA
/home/brandes/workspace/LAMA/src/lama/ReadAccess.hpp
Go to the documentation of this file.
00001 
00033 #ifndef LAMA_READ_ACCESS_HPP_
00034 #define LAMA_READ_ACCESS_HPP_
00035 
00036 // for dll_import
00037 #include <lama/config.hpp>
00038 
00039 // base classes
00040 #include <lama/BaseAccess.hpp>
00041 
00042 // others
00043 #include <lama/LAMAArray.hpp>
00044 #include <lama/Context.hpp>
00045 #include <lama/LAMAArrayView.hpp>
00046 
00047 #include <lama/exception/Exception.hpp>
00048 
00049 // logging
00050 #include <logging/logging.hpp>
00051 
00052 namespace lama
00053 {
00054 
00062 template<typename T>
00063 class LAMA_DLL_IMPORTEXPORT ReadAccess : public BaseAccess
00064 {
00065 public:
00069     typedef T ValueType;
00070 
00078     ReadAccess( const LAMAArray<ValueType>& array, ContextPtr context );
00079 
00080     ReadAccess( const LAMAArrayView<ValueType>& view, ContextPtr context );
00081 
00082     ReadAccess( const LAMAArrayConstView<ValueType>& view, ContextPtr context );
00083 
00087     virtual ~ReadAccess();
00088 
00094     const ValueType* get() const;
00095 
00102     virtual void release();
00103 
00104     virtual void writeAt(std::ostream& stream) const;
00105 
00111     inline IndexType size() const;
00112 
00113 private:
00114 
00115     const LAMAArrayConstView<ValueType>* mArrayView;
00116 
00117     size_t mIndex;
00118 
00119     LAMA_LOG_DECL_STATIC_LOGGER(logger);
00120 };
00121 
00122 template<typename T>
00123 inline IndexType ReadAccess<T>::size() const
00124 {
00125     return mArrayView->size();
00126 }
00127 
00128 }
00129 
00130 #endif // LAMA_READ_ACCESS_HPP_