Defined in file: hzDatabase.h
HDB Data Object Repository The class definition sets out the form objects of the class will have, but not how such objects are collected. What object members will be indexed, and whether objects must be unique in some way, are matters for the repository. To this end there is an initialization sequence. The repository member function InitStart() takes the predefined data class, names the repository and thus the data file, and it names the working directory. After calling InitStart() and before calling InitDone() to conclude initialization, you may call:- 1) InitMbrIndex() To add an index to a mamber - as long as the member is indexable member and does not already have an index. 2) InitMbrStore() Both OBJECT repositories store binary member data in a BINARY repository. This fn names which one. As this is part of overal program initialization, both these functions terminate execution if called on members with incompatible types. Note that Fetch() fetches the data object into a hdbObject recepticle but in the case of BINARY members, only the address of the binary datum value is loaded, not the value itself. This saves time in the common case where a BINARY member value is not needed by the data process. The value is loaded into the object by hdbObject::GetBinary(), and to support this, the hdbObjRepos class has a GetBinary() function (see below).
Constructors/Detructors
| hdbObjRepos* | hdbObjRepos | (void) | |
| hdbObjRepos* | hdbObjRepos | (hdbObjRepos&) | |
| hdbObjRepos* | hdbObjRepos | (hdbADP& adp) | |
| NULL-TYPE | hdbObjRepos | (hdbADP& adp) | |
| void | ~hdbObjRepos | (void) | |
| NULL-TYPE | ~hdbObjRepos | (void) |
Public Methods:
| hdbBinRepos* | BinRepos | (void) | |
| hdbClass* | Class | (void) | |
| const char* | Classname | (void) | |
| hzEcode | Clear | (void) | Destroys all data in the Ram table and re-initializes everything. Arguments: None |
| hzEcode | CommitEDO | (hzChain& edo)uint32_t objId, bool bLoad, | Commit an EDO to the cache. If the supplied object Id is 0, the EDO is a new object so the commit is an INSERT - in which case the object will be placed at the end, and the id issued in respect of it, will be the highest thusfar issues. If the supplied object id is non-zero, the commit is an UPDATE and it must be of an object that already exists and has not been deleted. In an UPDATE, the supplied EDO replaces the existing EDO. The supplied EDO may be shorter, longer, or the same size as the existing EDO. If the same size, the existing EDO is overwritten, otherwise the cache block is recreated. All data up to the existing EDO is copied to a new block, the supplied EDO is then added to the new block, then all data after the existing EDO is copied over - then the new block replaces the old. |
| uint32_t | Count | (void) | |
| hzEcode | Delete | (uint32_t objId) | Delete the object with the supplied object id. This results in the following action:- A delete marker is added to the delta file If the repository has a cache, the object EDO will be removed from it. The whole object delta is NOT removed from the internal binary repository, m_pBR_Delta. This will wait until rationalization. |
| uint32_t | DeltaId | (void) | |
| void | DescRepos | (hzChain& Z)uint32_t nIndent, | Export Repository Description Write out XML fragment describing the data object repository to the supplied chain. The anticipated use of this function is as part of an ADP export, so the supplied chain is not cleared. Returns: None |
| bool | Exists | (uint32_t objId) | |
| hzEcode | Exists | (uint32_t& objId)hdbMember* pMbr, hzAtom& value, | Identify a single object by matching on the supplied member name and value. Returns@ E_NOINIT If the object cache is not initialized E_CORRUPT If the member does not exist within the cache data class E_NODATA If the member is not indexed E_OK If no errors occured |
| hzEcode | Fetch | (hdbObject& obj)uint32_t objId, | Fetch populates the supplied object recipticle (hdbObject instance) with the object identified by the supplied object id. The supplied recepticle is cleared by this function. If the supplied object id is invalid, the recepticle is left blank |
| hzEcode | FetchEDO | (hzChain& edo)uint32_t objId, | Fetch the EDO indicated by the supplied object id, into the supplied chain |
| hzEcode | GetBinary | (hzChain& Z)hdbMember* pMbr, uint32_t objId, | Populate the supplied chain with the binary object held by the named member in the identified data object. This assumes the named data class member holds binary objects and that the supplied data object id is valid. As object repositories do not directly hold binary values, the member value will be the address of the binary object residing in a separate binary repository. The address is then used in a Fetch() on the binary repository. |
| hdbMember* | GetMember | (hzString name) | |
| hzEcode | InitDone | (void) | Complete repository initialization. Deal with files if the working directory has been supplied. If files bearing the repository name exists in the stated working directory, these are assumed to be data files and will be read in to populate the repository. Delta files begin with a header which must match the class definition. This is checked before loading the rest of the data. If a file of the cache's name does not exist in the working directory, it will be created and a header will be written. If a backup directory has been specified and a file of the cache's name exists in this directory, the header will be checked and assuming this is OK, the length of the file will aslo be checked (should match with that in the work directory) Arguments: None |
| hzEcode | InitMbrIndex | (hdbMember* pMbr)bool bUnique, | Add an index based on the supplied member name. Find the member in the class and from the datatype, this will determine which sort of index should be set up. |
| hzEcode | InitMbrIndex | (hzString& mbrName)bool bUnique, | Add an index based on the supplied member name. Find the member in the class and from the datatype, this will determine which sort of index should be set up. |
| hzEcode | InitMbrRepos | (hzString& mbrName)hzString& reposName, | By default subclass data objects are embedded within host class data objects. This function directs the repository to hold subclass data objects in another repository. This is done on a per-member basis and only applies to member with of a CLASS data type. |
| hzEcode | InitStart | (hdbClass* pNative)hzString& name, hzString& workdir, hdbReposMode eMode, | Begin repository initialization sequence. This function sets the repository native class, names the repository and the working directory (location of data files). Once this function has completed, it may be followed by calls to InitMbrIndex() to add member-wise indexes to the repository. Lastly InitDone() is called to complete the process. |
| hdbIniStat | InitState | (void) | |
| hzEcode | Insert | (uint32_t& objId)hdbObject& theObj, | The INSERT operation adds a new data object to a repository and creates a new object id in respect of it. If any indexes apply, these are updated accordingly. Note that in INSERT operations, the supplied object is expected to be an entirely new, and whole, object of the repository native data class. All subclass objects will have been added to the native class data object, prior to this function call. Because the supplied data object is entirely new, a whole object delta is generated. In all cases the new data object is committed to a binary datum repository as a whole object delta. If RAM Primacy applies, the new data object is also written as an EDO to repository cache. The whole object delta is produced by calling ExportDelta() on the supplied object. The EDO is produced by calling ExportEDO() on the supplied object. If the object has populated BINARY or TXTDOC members, their values are committed to the applicable binary datum repository before the delta and EDO exports. This is so that the values are assigned datum ids - which are the only representation the values will have in the delta and in the EDO. |
| bool | IsInit | (void) | |
| hdbObjRepos* | ObjRepos | (hdbMember* pMbr) | Locate the external repository associated with a subclass member. This will either be the repository itself or that specified during initialization InitMbrRepos() Pointer to the external repository if found, 0 otherwise |
| hzEcode | Open | (void) | Open the data object repository, i.e. ready it for data operations. Depending on repository configuration, this action will do the following:- Open the binary repository for Whole Object Deltas. This is done in all cases. This action restores RAM Primacy components to the last known data state. Now deal with files if the working directory has been supplied. If a file of the cache's name exists in the working directory, this is assumed to be the data file and will be read in to populate the cache. The file must begin with a header which must match the class definition so this is checked before loading the remaining data. If a file of the cache's name does not exist in the working directory, it will be created and a header will be written. If a backup directory has been specified and a file of the cache's name exists in this directory, the header will be checked and assuming this is OK, the length of the file will aslo be checked (should match with that in the work directory) Arguments: None |
| hzEcode | Select | (hzIntset& result)const char* cpSQL, | Select data objects according to the supplied search criteria (arg 2), and populate the supplied hzIntset with the object ids. The parse process is rudimentary, so SQL-esce rather than strict SQL. Each search criteria term will produce an idset result. OR and AND operations are applied where there are multiple terms. If these operations are not stated, AND is assumed. |
| uint32_t | SeqId | (void) | |
| hzEcode | Update | (hdbObject& obj)uint32_t objId, | Overwrite the object found at the supplied address, with the supplied object and update any affected indexes accordingly DEPRECATED |
| void | _deltaWrite | (void) | |
| void | _initerr | (hzFuncname& _fn)uint32_t nExpect, | |
| hzEcode | _loadCache | (void) | Load whole object deltas |
| hzEcode | _loadDeltas | (void) | Load data from delta files. Loads both whole object and member deltas. Note that member deltas are ignored unless the host object exists within the repository. |
| hzEcode | _updateIdx | (hdbObject& obj) | Supprt function. Updates the repository indexes on behalf of Insert() and _loadDeltas() |
| hzString | strName | (void) | |
| const char* | txtName | (void) |
Overloaded operators:
| hdbObjRepos& | operator= | (hdbObjRepos&) |
Member Variables:
| hzMapS<uint32_t,hzEdo> | m_Cache | RAM Primacy data area (if applicable) | |
| uint16_t | m_DeltaId | Repository id (as per the ADP) | |
| hzString | m_Name | The unique repository name. The name serves as a base for the various repository data files | |
| unsigned char | m_Resv | Reserved | |
| hzString | m_Workdir | The working directory. All repository data files go here. | |
| unsigned char | m_bBinaries | Repository native has one or more BINARY/TXTDOC members (and thus a named binary datum repos for storing member datum) | |
| hdbReposMode | m_eMode | Operation mode | |
| hdbIniStat | m_eReposInit | Controls initialization | |
| hzMapS<uint16_t,hdbIndex*> | m_mapIndex | Map of members to indexes | |
| hzMapS<uint16_t,hdbObjRepos*> | m_mapRepos | Map of members to external data object repositories (if applicable) | |
| uint32_t | m_nPopulation | Population | |
| uint32_t | m_nSeqId | Highest object id thus far issued | |
| hzString | m_nameBR_Datum | Datum binary repository name (m_Name + _br_datum) | |
| hzString | m_nameBR_Delta | Delta binary repository name (m_Name + _br_delta) | |
| ofstream | m_osDelta | Output stream to delta file | |
| hdbADP* | m_pADP | Host ADP | |
| hdbBinRepos* | m_pBR_Datum | hdbBinRepos for storing datum on behalf of TEXT, TXTDOC or BINARY members | |
| hdbBinRepos* | m_pBR_Delta | hdbBinRepos for storing objects as whole object deltas | |
| hdbClass* | m_pClass | Native data object class | |
| hzString | m_pathCD | Name of cache delta file if applicable (m_Name + _cache.delta) |