--- trunk/OOPSE-4/src/brains/BlockSnapshotManager.hpp 2005/02/13 08:05:33 2006 +++ trunk/OOPSE-4/src/brains/BlockSnapshotManager.hpp 2005/02/15 19:36:07 2035 @@ -40,6 +40,7 @@ */ #ifndef BRAINS_BLOCKSNAPSHOTMANAGER_HPP #define BRAINS_BLOCKSNAPSHOTMANAGER_HPP +#include #include "brains/SnapshotManager.hpp" namespace oopse { @@ -53,13 +54,13 @@ class BlockSnapshotMananger : public SnapshotManager{ * @class BlockSnapshotManager * @todo document */ -class BlockSnapshotMananger : public SnapshotManager{ +class BlockSnapshotManager : public SnapshotManager{ public: - BlockSnapshotMananger(SimInfo* info, const std::string& filename, int storageLayout, int blockCapacity = 2); - ~BlockSnapshotMananger(); + BlockSnapshotManager(SimInfo* info, const std::string& filename, int storageLayout, int blockCapacity = 2); + ~BlockSnapshotManager(); - virtual Snapshot* getSnapshot(int id); + virtual Snapshot* getSnapshot(int id) { return snapshots_[id]; } /** Returns number of snapshot blocks in this BlockSnapshotManager*/ int getNBlocks() { @@ -72,8 +73,11 @@ class BlockSnapshotMananger : public SnapshotManager{ int getNActiveBlocks(); - bool isBlockActive(int block); - + + bool isBlockActive(int block) { + return findActiveBlock(block) != activeBlocks_.end() ? true : false; + } + bool loadBlock(int block); bool unloadBlock(int block); @@ -88,15 +92,25 @@ class BlockSnapshotMananger : public SnapshotManager{ private: + std::vector::iterator findActiveBlock(int block) { + return std::find(activeBlocks_.begin(), activeBlocks_.end(), block); + } + + bool hasZeroRefBlock(); + + int getFirstZeroRefBlock(); + + void internalLoad(int block); + void internalUnload(int block); Snapshot* loadFrame(int frame); SimInfo* info_; - int storageLayout_; int blockCapacity_; std::vector snapshots_; std::vector blocks_; std::vector activeBlocks_; + std::vector activeRefCount_; int nAtoms_; int nRigidBodies_;