MASA-Core
SpecialRowRAM.hpp
Go to the documentation of this file.
00001 /*******************************************************************************
00002  *
00003  * Copyright (c) 2010-2015   Edans Sandes
00004  *
00005  * This file is part of MASA-Core.
00006  * 
00007  * MASA-Core is free software: you can redistribute it and/or modify
00008  * it under the terms of the GNU General Public License as published by
00009  * the Free Software Foundation, either version 3 of the License, or
00010  * (at your option) any later version.
00011  * 
00012  * MASA-Core is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  * 
00017  * You should have received a copy of the GNU General Public License
00018  * along with MASA-Core.  If not, see <http://www.gnu.org/licenses/>.
00019  *
00020  ******************************************************************************/
00021 
00022 #ifndef SPECIALROWRAM_HPP_
00023 #define SPECIALROWRAM_HPP_
00024 
00025 #include "SpecialRow.hpp"
00026 
00027 /** @brief Class that reads and stores an Special Row in the RAM memory.
00028  *
00029  * This class is the implementation of a SpecialRow that stores the cells
00030  * in RAM memory. Consider that the row stored by this class is not persistent,
00031  * so it is not susceptible to chekpoint restore.
00032  *
00033  */
00034 class SpecialRowRAM : public SpecialRow {
00035 public:
00036         /**
00037          * Creates a new Special Row associated to the RAM memory.
00038          * @param id the rowId
00039          */
00040         SpecialRowRAM(int id);
00041 
00042         /**
00043          * Dispose the RAM memory allocated to this object.
00044          */
00045         virtual ~SpecialRowRAM();
00046 
00047         /**
00048          * Does nothing.
00049          */
00050         virtual void close();
00051 
00052         /**
00053          * Truncates the allocated memory.
00054          *
00055          * @param size the number of cells to keep in the memory.
00056          */
00057         virtual void truncateRow(int size);
00058 
00059 private:
00060         /** Allocated memory. */
00061         cell_t* row;
00062 
00063         /** Length of the allocated memory */
00064         int length;
00065 
00066         /**
00067          * Allocate the initial structure for this row
00068          *
00069          * @param readOnly true if it must be opened for read mode, false otherwise.
00070          * @param length the initial size of the row in memory.
00071          */
00072         virtual void initialize(bool readOnly, int length);
00073 
00074         /*
00075          * @see description in superclass header.
00076          */
00077         virtual int write(const cell_t* buf, int offset, int len);
00078 
00079         /*
00080          * @see description in superclass header.
00081          */
00082         virtual int read(cell_t* buf, int offset, int len);
00083 };
00084 
00085 #endif /* SPECIALROWRAM_HPP_ */