InfoHog
Topics
:Overview
Conditional Directives
Constants
Type Definitions
Enumerations
Data Structures
Functions
InfoHog is a general-purpose platform interoperable database application used store any type of binary data. InfoHog data is organized in a member array with the first member representing a fixed length primary key. The key type must be defined by the application or derived class when InfoHog objects are constructed. All other array elements can be any built-in or user defined type known to the application or the derived class. The application or the derived class is responsible for type casting the members of the object array to the correct type. The member array is variable in length for both in-memory copies and disk copies of InfoHog objects. This feature allows applications or a derived class to add or subtract fields from database records without having to rebuild the database. Using InfoHog you can rapidly assemble any type of relational or object-oriented database.
InfoHog Constants
const unsigned InfoHogMinMembers = 1; // Minimum number of members const unsigned InfoHogDefMembers = 9; // Default number of members const unsigned InfoHogMaxMembers = 255; // Maximum number of members const unsigned InfoHogNameLength = 256; // Default name lengths // Default number of keys per tree node const BtreeNodeOrder_t InfoHogNodeOrder = 11; // Default Class ID for InfoHog objects const gxClassID ClassInfoHogID = (gxClassID)-1; // This infohog configuration will allow 255 Btree indexes per index file // and 255 static data entries per data file. const int InfoHogNumTrees = 255; // Max number of Btrees per index file const int InfoHogUseIndexFile = 1; // Used to enable the use of index files const FAU InfoHogStaticArea = FAU_t(255 * 255); // Static data area
Persistent Object Database Manager Constants
The InfoHog key type class is used to define the primary key type used by this database.
template<class TYPE> class InfoHogKey_t { public: InfoHogKey_t() { } ~InfoHogKey_t() { } public: // Persistent data members // NOTE: Do not change the ordering of the data members in order to // maintain a uniform byte alignment between the in-memory copy of // the object and the copy stored on disk. If the member alignment // is changed all database files using this structure will have to // be rebuilt. TYPE object_name; // Object name gxObjectID object_id; // Object data file address/identification number gxClassID class_id; // Optional object class identification number };
The InfoHog key class is derived from the DatabaseKeyB base class and defines the primary key class used by this database.
template<class TYPE> class InfoHogKey : public DatabaseKeyB { public: InfoHogKey(int dup_names = 0); InfoHogKey(TYPE &name, gxObjectID oid = (gxObjectID_t)0, gxClassID cid = (gxClassID_t)0, int dup_names = 0); public: // Base class interface size_t KeySize() { return sizeof(key); } int operator==(const DatabaseKeyB& k) const; int operator>(const DatabaseKeyB& k) const; public: TYPE &ObjectName() { return key.object_name; } gxObjectID ObjectID() const { return key.object_id; } gxClassID ClassID() const { return key.class_id; } void SetObjectName(const TYPE &name) { key.object_name = name; } void SetObjectName(TYPE &name) { key.object_name = name; } void SetObjectID(gxObjectID oid) { key.object_id = oid; } void SetClassID(gxClassID cid) { key.class_id = cid; } void AllowDuplicates() { allow_dup_names = 1; } void DisallowDuplicates() { allow_dup_names = 0; } private: // Non-persistent data members int allow_dup_names; private: // Persistent data members InfoHogKey_t<TYPE> key; };
InfoHogKey::InfoHogKey()
InfoHogKey::AllowDuplicates()
InfoHogKey::ClassID()
InfoHogKey::DisallowDuplicates()
InfoHogKey::KeySize()
InfoHogKey::ObjectID()
InfoHogKey::SetClassID()
InfoHogKey::SetObjectID()
InfoHogKey::SetObjectName()
InfoHogKey::ObjectName()
InfoHogKey::InfoHogKey(int dup_names = 0)
- Default class constructor. By default duplicate key names are not allowed.InfoHogKey::InfoHogKey(TYPE &name, gxObjectID oid = (gxObjectID_t)0, gxClassID cid = (gxClassID_t)0, int dup_names = 0)
- Class constructor used to set the key name, object ID, class ID, and enable duplicate names.void InfoHogKey::AllowDuplicates()
- Public member function used to enable duplicate names.gxClassID InfoHogKey::ClassID()
- Public member function that returns the class ID of this key.void InfoHogKey::DisallowDuplicates()
- Public member function use to disallow duplicate names. - Public member function that returns the key size.gxObjectID InfoHogKey::ObjectID()
- Public member function that returns the object ID of this key.void InfoHogKey::SetClassID(gxClassID cid)
- Public member function used to set the class ID of this key.void InfoHogKey::SetObjectID(gxObjectID oid)
- Public member function used to set the object ID of this key.void InfoHogKey::SetObjectName(const TYPE &name)
- Public member function used to set the primary key name.TYPE &InfoHogKey::ObjectName()
- Public member function that returns a reference to the primary key name.InfoHog::InfoHog()
InfoHog::~InfoHog()
InfoHog::AllocArray()
InfoHog::ChangeKeyMember()
InfoHog::ChangeMember()
InfoHog::ChangeObject()
InfoHog::CompareIndex()
InfoHog::Copy()
InfoHog::Delete()
InfoHog::DeleteArray()
InfoHog::Find()
InfoHog::GetClassID()
InfoHog::GetMember()
InfoHog::GetMemberArray()
InfoHog::GetMemberLen()
InfoHog::GetNumMembers()
InfoHog::GetObjectID()
InfoHog::ObjectLength()
InfoHog::OverWriteObject()
InfoHog::Read()
InfoHog::RebuildIndexFile()
InfoHog::SetClassID()
InfoHog::SetMember()
InfoHog::SetObjectID()
InfoHog::Write()
InfoHog::InfoHog(POD *pod, unsigned members = InfoHogDefMembers) - Class constructor used to initialize the POD pointer and allocated memory for the InfoHog member array.
InfoHog::InfoHog(const POD *pod, unsigned members = InfoHogDefMembers)
- Class constructor used to initialize the POD pointer and allocated memory for the InfoHog member array.InfoHog::InfoHog(POD *pod, const TYPE &key, unsigned members = InfoHogDefMembers)
- Class constructor used to initialize the POD pointer, set the key name, and allocated memory for the InfoHog member array.InfoHog::InfoHog(const POD *pod, const TYPE &key, unsigned members = InfoHogDefMembers)
- Class constructor used to initialize the POD pointer, set the key name, and allocated memory for the InfoHog member array. - Default class constructorInfoHog::InfoHog(const InfoHog<TYPE> &ob)
- Class constructor copy constructor.void InfoHog::operator=(const InfoHog<TYPE> &ob)
- InfoHog assignment operator.virtual InfoHog::~InfoHog()
- Class destructor responsible for de-allocating memory for the InfoHog member array when an InfoHog object is destroyed.int InfoHog::AllocArray(unsigned num)
- Protected member function used to allocate memory for the object array. The length of the member array will be equal to the number of array elements multiplied by the size of a MemoryBuffer object. NOTE: This function will not allocate memory for the array if the current object array is large enough to hold the number of elements requested. Returns true if allocation is successful or false if a memory allocation error occurs.int InfoHog::ChangeKeyMember(TYPE &k, int find_object = 1)
- Public member function used to change this object's key name. If the "find_object" variable is true this function will obtain the object's data file address and load the object. Returns true if successful or false if the object could not be changed.int InfoHog::ChangeMember(const void *ob, unsigned len, unsigned index, int find_object = 1)
- Public member function used to change the object array member at the specified array index. If the "find_object" variable is true this function will obtain the object's data file address and load the object. Returns true if successful or false if the object could not be changed.int InfoHog::ChangeObject(InfoHog<TYPE> &ob, int find_object = 1)
- Public member function used to change this object. If the "find_object" variable is true this function will obtain the object's data file address and load the object. Returns true if successful or false if the object could not be changed.int InfoHog::CompareIndex(unsigned index_number)
- Public member function used to compare the data file to the specified index file. Returns true if data and index file match.int InfoHog::Copy(const InfoHog<TYPE> &ob, int copy_pod_vars = 1)
- Public member function used to copy the contents of the specified object into this object. If the "copy_pod_vars" variable is true the POD and data file address pointers plus all other POD variables will be copied as well as the object's data members. NOTE: This function assumes that memory has been allocated for the "ob" object array. - Private member function used by the Persistent base class to delete InfoHog objects. Returns true if successful or false if the object could not be deleted. - Protected member function used to free the memory used for the object array and reset the array variables. - Private member function used by the Persistent base class to find InfoHog objects. Returns true if successful or false if the object could not be found.gxClassID InfoHog::GetClassID()
- Public member function that returns the optional class ID of this object.unsigned char *InfoHog::GetMember(unsigned index)
- Public member function that returns a pointer to the specified member of the object array. If the index is out of bounds or no memory has been allocated for the member array this function will return a null value.MemoryBuffer *InfoHog::GetMemberArray()
- Public member function that returns a pointer to the InfoHog object array.unsigned InfoHog::GetMemberLen(unsigned index)
- Public member function that returns the length of the specified member in the object array. If the index is out of bounds or no memory has been allocated for the member array this function will return zero.unsigned InfoHog::GetNumMembers()
- Public member function that returns the number of members this object is currently using.gxObjectID InfoHog::GetObjectID()
- Public member function that returns the object ID of the object. NOTE: The object ID also represents the object's data file address, which is guaranteed to be unique for every object.__UWORD__ InfoHog::ObjectLength()
- Private member function used by the Persistent base class to calculate the length of this object based on total number of InfoHog data members:[num_members][len_record*num_members][member_len*num_members]
int InfoHog::OverWriteObject(FAU object_address)
- Public member function used to overwrite the object at the specified object address. NOTE: This function assumes that objects are fixed in length and will not overwrite the object's key name. Returns true if successful or false if an error occurs.int InfoHog::OverWriteObject()
- Public member function used to overwrite this object. NOTE: This function assumes that objects are fixed in length and will not overwrite the object's key name. Returns true if successful or false if an error occurs.gxDatabaseError InfoHog::Read(FAU Address)
- Private member function used by the Persistent base class to read InfoHog objects. Returns zero if successful or a non-zero value corresponding to a gxDatabaseError enumerated type if an error occurs. - Public member function used to rebuild a damaged index file. Returns the total number of members inserted into the new index file or zero if an error occurs.void InfoHog::SetClassID(gxClassID cid)
- Public member function used to set the optional class ID of this object.int InfoHog::SetMember(const void *ob, unsigned len, unsigned index)
- Public member function used to set a member of the object array. NOTE: The primary key will always be index number 0. Returns true if the member was set or false if an error occurred.void InfoHog::SetObjectID(gxObjectID oid)
- Public member function used to set the object ID of this object. NOTE: The object ID also represents the object's data file addressgxDatabaseError InfoHog::Write()
- Private member function used by the Persistent base class to write InfoHog objects. Returns zero if successful or a non-zero value corresponding to a gxDatabaseError enumerated type if an error occurs.
End Of Document |