MCPcopy Create free account
hub / github.com/Tripwire/tripwire-open-source / cBlockRecordArray

Class cBlockRecordArray

src/db/blockrecordarray.h:54–235  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

52class eArchive;
53
54class cBlockRecordArray
55{
56public:
57 //-------------------------------------------------------------------------------------
58 // Construction
59 //-------------------------------------------------------------------------------------
60 cBlockRecordArray(cBlockFile* pBlockFile, int blockNum);
61 // this object is associated with a single block in a cBlockFile. It is _not_
62 // asserted that the blockNum is valid for the associated file at this point,
63 // since it is possible that the file has not been loaded yet
64 cBlockRecordArray();
65 // if this version of the ctor is called, then Init() must be called before it can be used.
66 void Init(cBlockFile* pBlockFile, int blockNum);
67
68 virtual ~cBlockRecordArray();
69
70 //-------------------------------------------------------------------------------------
71 // Initialization ... exactly one of these methods must be called before this class can be used
72 //-------------------------------------------------------------------------------------
73 void InitNewBlock(); //throw (eArchive)
74 // this method should be called when a new block has been created, and before this
75 // class operates on it.
76 void InitForExistingBlock(); //throw (eArchive)
77 // this method should be called to initialize this class for use with a block that has
78 // previously been created and initialized with InitNewBlock().
79
80 //-------------------------------------------------------------------------------------
81 // Data Manipulation
82 //-------------------------------------------------------------------------------------
83 int AddItem(int8* pData, int dataSize, int mainIndex); //throw (eArchive)
84 // inserts the given item into the array; returns the index that it was inserted into.
85 // this asserts that there is room for the new element, and updates the avail. space and
86 // max index as necessary.
87 void DeleteItem(int index); //throw (eArchive)
88 // deletes the specified item; this asserts that the index is valid, and updates the avail.
89 // space and max index as necessary.
90 int8* GetDataForReading(int index, int32& dataSize); //throw (eArchive)
91 // returns a pointer to the named data. This method will assert that the address is
92 // valid. The data pointer returned is guarenteed to be valid only until the next
93 // method call into this class.
94 int8* GetDataForWriting(int index, int32& dataSize); //throw (eArchive)
95 // this is the same as the previous function, except the dirty bit for the page is also set
96 bool IsItemValid(int index) const; //throw (eArchive)
97 // returns true if the given index has a valid value.
98
99 bool IsClassValid() const;
100 // returns true if the class has an internally consistant state. If an archive exception
101 // occurs, false is returned. This method is good for determining if a newly opened block
102 // file is actually a block file
103
104 bool Initialized() const
105 {
106 return mbInit;
107 }
108 int GetAvailableSpace() const
109 {
110 ASSERT(Initialized());
111 return mSpaceAvailable;

Callers 2

OpenImplMethod · 0.85
FindRoomForDataMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected