| 40 |
|
*/ |
| 41 |
|
#ifndef BRAINS_BLOCKSNAPSHOTMANAGER_HPP |
| 42 |
|
#define BRAINS_BLOCKSNAPSHOTMANAGER_HPP |
| 43 |
+ |
#include <vector> |
| 44 |
|
|
| 45 |
|
#include "brains/SnapshotManager.hpp" |
| 46 |
|
namespace oopse { |
| 47 |
|
|
| 48 |
< |
class SimInfo; |
| 49 |
< |
class DumpReader; |
| 48 |
> |
class SimInfo; |
| 49 |
> |
class DumpReader; |
| 50 |
|
|
| 51 |
< |
typedef std::pair<int, int> SnapshotBlock; |
| 51 |
> |
typedef std::pair<int, int> SnapshotBlock; |
| 52 |
|
|
| 53 |
< |
/** |
| 54 |
< |
* @class BlockSnapshotManager |
| 55 |
< |
* @todo document |
| 56 |
< |
*/ |
| 57 |
< |
class BlockSnapshotMananger : public SnapshotManager{ |
| 53 |
> |
/** |
| 54 |
> |
* @class BlockSnapshotManager |
| 55 |
> |
* @todo document |
| 56 |
> |
*/ |
| 57 |
> |
class BlockSnapshotManager : public SnapshotManager{ |
| 58 |
|
|
| 59 |
< |
public: |
| 60 |
< |
BlockSnapshotMananger(SimInfo* info, const std::string& filename, int storageLayout, int blockCapacity = 2); |
| 61 |
< |
~BlockSnapshotMananger(); |
| 59 |
> |
public: |
| 60 |
> |
BlockSnapshotManager(SimInfo* info, const std::string& filename, int storageLayout, int blockCapacity = 2); |
| 61 |
> |
~BlockSnapshotManager(); |
| 62 |
|
|
| 63 |
< |
virtual Snapshot* getSnapshot(int id); |
| 63 |
> |
virtual Snapshot* getSnapshot(int id) { return snapshots_[id]; } |
| 64 |
|
|
| 65 |
< |
/** Returns number of snapshot blocks in this BlockSnapshotManager*/ |
| 66 |
< |
int getNBlocks() { |
| 67 |
< |
return blocks_.size(); |
| 68 |
< |
} |
| 65 |
> |
/** Returns number of snapshot blocks in this BlockSnapshotManager*/ |
| 66 |
> |
int getNBlocks() { |
| 67 |
> |
return blocks_.size(); |
| 68 |
> |
} |
| 69 |
|
|
| 70 |
< |
SnapshotBlock getSnapshotBlock(int block) { |
| 71 |
< |
return blocks_.at(block); |
| 72 |
< |
} |
| 70 |
> |
SnapshotBlock getSnapshotBlock(int block) { |
| 71 |
> |
return blocks_.at(block); |
| 72 |
> |
} |
| 73 |
|
|
| 74 |
< |
int getNActiveBlocks(); |
| 74 |
> |
int getNActiveBlocks(); |
| 75 |
> |
|
| 76 |
> |
void needCOMprops(bool ncp); |
| 77 |
> |
|
| 78 |
> |
|
| 79 |
> |
bool isBlockActive(int block) { |
| 80 |
> |
return findActiveBlock(block) != activeBlocks_.end() ? true : false; |
| 81 |
> |
} |
| 82 |
> |
|
| 83 |
> |
bool loadBlock(int block); |
| 84 |
|
|
| 85 |
< |
bool isBlockActive(int block); |
| 76 |
< |
|
| 77 |
< |
bool loadBlock(int block); |
| 78 |
< |
|
| 79 |
< |
bool unloadBlock(int block); |
| 85 |
> |
bool unloadBlock(int block); |
| 86 |
|
|
| 87 |
< |
std::vector<int> getActiveBlocks(); |
| 87 |
> |
std::vector<int> getActiveBlocks(); |
| 88 |
|
|
| 89 |
< |
int getBlockCapacity() { |
| 90 |
< |
return blockCapacity_; |
| 91 |
< |
} |
| 89 |
> |
int getBlockCapacity() { |
| 90 |
> |
return blockCapacity_; |
| 91 |
> |
} |
| 92 |
|
|
| 93 |
< |
int getNFrames() { |
| 88 |
< |
return reader_->getNFrames(); |
| 89 |
< |
} |
| 93 |
> |
int getNFrames(); |
| 94 |
|
|
| 95 |
< |
private: |
| 95 |
> |
private: |
| 96 |
|
|
| 97 |
< |
Snapshot* loadFrame(int frame); |
| 97 |
> |
std::vector<int>::iterator findActiveBlock(int block) { |
| 98 |
> |
return std::find(activeBlocks_.begin(), activeBlocks_.end(), block); |
| 99 |
> |
} |
| 100 |
> |
|
| 101 |
> |
bool hasZeroRefBlock(); |
| 102 |
> |
|
| 103 |
> |
int getFirstZeroRefBlock(); |
| 104 |
> |
|
| 105 |
> |
void internalLoad(int block); |
| 106 |
> |
void internalUnload(int block); |
| 107 |
> |
Snapshot* loadFrame(int frame); |
| 108 |
|
|
| 109 |
< |
SimInfo* info_; |
| 110 |
< |
int storageLayout_; |
| 97 |
< |
int blockCapacity_; |
| 109 |
> |
SimInfo* info_; |
| 110 |
> |
int blockCapacity_; |
| 111 |
|
|
| 112 |
< |
std::vector<Snapshot*> snapshots_; |
| 113 |
< |
std::vector<SnapshotBlock> blocks_; |
| 114 |
< |
std::vector<int> activeBlocks_; |
| 112 |
> |
std::vector<Snapshot*> snapshots_; |
| 113 |
> |
std::vector<SnapshotBlock> blocks_; |
| 114 |
> |
std::vector<int> activeBlocks_; |
| 115 |
> |
std::vector<int> activeRefCount_; |
| 116 |
|
|
| 117 |
< |
int nAtoms_; |
| 118 |
< |
int nRigidBodies_; |
| 117 |
> |
int nAtoms_; |
| 118 |
> |
int nRigidBodies_; |
| 119 |
|
|
| 120 |
< |
DumpReader* reader_; |
| 121 |
< |
int nframes_; |
| 122 |
< |
int nSnapshotPerBlock_; |
| 120 |
> |
DumpReader* reader_; |
| 121 |
> |
int nframes_; |
| 122 |
> |
int nSnapshotPerBlock_; |
| 123 |
|
|
| 124 |
< |
}; |
| 124 |
> |
}; |
| 125 |
|
|
| 126 |
|
} |
| 127 |
|
|