//****************************************************************************** //****************************************************************************** // Code disclaimer information //------------------------------------------------------------------------------ // This file contains programming code examples. // // IBM grants you a nonexclusive copyright license to use all programming // code examples from which you can generate similar functions tailored to // your own specific needs. // // All sample code is provided by IBM for illustrative purposes only. // These examples have not been thoroughly tested under all conditions. IBM, // therefore, cannot guarantee or imply reliability, serviceability, or // function of these programs. // // All programs contained herein are provided to you "AS IS" without any // warranties of any kind. The implied warranties of non-infringement, // merchantability, and fitness for a particular purpose are expressly // disclaimed. //****************************************************************************** //****************************************************************************** #ifndef _FIDTBL_H #define _FIDTBL_H //-- START OF SPECIFICATIONS ------------------------------------------------ // // Header File Name : fidtbl.H // // Descriptive Name : File ID table class // // // Description : Include file containing the class definitions // for FIDTable and FIDTableEntry. This is a simple // implementation of File ID mapping between a // source and target system. However, please note // that the table is primed by assuming that the // source and target systems are the same system. // For demo purposes, we usually will only have one // iSeries system available, so we are using a remote // journal on the same source system. // //****** WARNING ***** PLEASE READ ME ****************************************** // USE OF THIS SOURCE CODE IS AT YOUR OWN RISK. // This code is being used in the IFS Journaling Replication demo that was // first used at COMMON in March 2003. This code is NOT a complete replication // solution, and should not be used to provide object or data replication. // It was written to provide a way to demo replication of a small subset of IFS // journal entries using a remote journal on the SAME system. It is being made // available for public browsing as an example what was really involved in // performing some of the steps required in providing IFS object/data // replication. Therefore, some of the code within this demo takes shortcuts // that would not be available in a normal replication environment involving // separate source and target systems. //****************************************************************************** // Change Activity : // // CFD List : // // FLAG REASON LEVEL DATE PGMR CHANGE DESCRIPTION // ---- ------------ ----- ------ --------- ----------------------- // $A0= DEMO xxxx 030129 IBMG8PA: New Include // // End CFD List. // // Additional notes about the Change Activity // // End Change Activity. // //-- END OF SPECIFICATIONS ------------------------------------------------- #include "rplcmn.H" #include #include class FIDTable; //---- START OF CLASS DEFINITION ----------------------------------------------- // // Class Name : FIDTableEntry // // Class Description : File ID Table Entry // // Implementation Part : fidtbl.C // // Dependencies : None // // Restrictions : None // // Public Data : See class // // Private Data : See class // // Notes : None. // //---- END OF CLASS DEFINITION ------------------------------------------------- class FIDTableEntry { public: //---- START OF MEMBER FUNCTION DEFINITION ------------------------------------- // // Member Function Name : FIDTableEntry (constructor) // // Function Description : Construct a FIDTableEntry object // // Parameters : // // srcFID (input) // Pointer to a FID for the source "system" object. // // tgtFID (input) // Pointer to a FID for the target "system" object. // // srcPathP (input) // Pointer to a NULL-terminated string, characters in CCSID 37, for the // source "system" object associated with srcFID. // // tgtPathP (input) // Pointer to a NULL-terminated string, characters in CCSID 37, for the // target "system" object associated with tgtFID. // // Return Value : None. // // Pre Conditions : None. // // Post Conditions : Entry is created. // // Side Effects : None. // // Error Conditions : None. // // Notes : None. // //---- END OF MEMBER FUNCTION DEFINITION --------------------------------------- FIDTableEntry(Qp0lFID_t inSrcFID, Qp0lFID_t inTgtFID, char *srcPathP, char *tgtPathP); ~FIDTableEntry() {}; private: friend class FIDTable; // The table needs much access to the entry. Qp0lFID_t srcFID; // Source system's FID for the srcPath. Qp0lFID_t tgtFID; // Target system's FID for the tgtPath. FIDTableEntry *nextP; // Pointer to next FIDTableEntry. Used by // FIDTable for linked list. FIDTableEntry *prevP; // Pointer to the previous FIDTableEntry. Used // by FIDTable for linked list. char srcPath[MAX_PATH_LENGTH]; // Source path. char tgtPath[MAX_PATH_LENGTH]; // Target path. }; //---- START OF CLASS DEFINITION ----------------------------------------------- // // Class Name : FIDTable // // Class Description : File ID Table // // Implementation Part : fidtbl.C // // Dependencies : None // // Restrictions : None // // Public Data : See class // // Private Data : See class // // Notes : None. // //---- END OF CLASS DEFINITION ------------------------------------------------- class FIDTable { public: //---- START OF MEMBER FUNCTION DEFINITION ------------------------------------- // // Member Function Name : FIDTable (constructor) // // Function Description : Construct a FIDTable object // // Parameters : // // srcDirPathP (input) // Pointer to a NULL-terminated string, characters in CCSID 37, for the // source "system" starting directory. // // tgtDirPathP (input) // Pointer to a NULL-terminated string, characters in CCSID 37, for the // target "system" starting directory. // // Return Value : None. // // Pre Conditions : None. // // Post Conditions : Table is created with 1 entry for the input paths. // // Side Effects : None. // // Error Conditions : None. // // Notes : None. // //---- END OF MEMBER FUNCTION DEFINITION --------------------------------------- FIDTable(char *srcDirPathP, char *tgtDirPathP); //---- START OF MEMBER FUNCTION DEFINITION ------------------------------------- // // Member Function Name : ~FIDTable (destructor) // // Function Description : Destruct a FIDTable object // // Parameters : None. // // Return Value : None. // // Pre Conditions : None. // // Post Conditions : Table, and all entries within it, is destroyed. // // Side Effects : None. // // Error Conditions : None. // // Notes : None. // //---- END OF MEMBER FUNCTION DEFINITION --------------------------------------- ~FIDTable(); //---- START OF MEMBER FUNCTION DEFINITION ------------------------------------- // // Member Function Name : addEntry // // Function Description : Add an entry to the FID Table. // // Parameters : // // srcFID (input) // Pointer to a FID for the source "system" object. // // tgtFID (input) // Pointer to a FID for the target "system" object. // // srcPathP (input) // Pointer to a NULL-terminated string, characters in CCSID 37, for the // source "system" object associated with srcFID. // // tgtPathP (input) // Pointer to a NULL-terminated string, characters in CCSID 37, for the // target "system" object associated with tgtFID. // // Return Value : None. // // Pre Conditions : None. // // Post Conditions : Entry is added to table. // // Side Effects : None. // // Error Conditions : None. // // Notes : None. // //---- END OF MEMBER FUNCTION DEFINITION --------------------------------------- int addEntry(Qp0lFID_t srcFID, Qp0lFID_t tgtFID, char *srcPathP, char *tgtPathP); //---- START OF MEMBER FUNCTION DEFINITION ------------------------------------- // // Member Function Name : rmvEntry // // Function Description : Remove an entry to the FID Table. // // Parameters : // // srcFID (input) // Pointer to the FID for the source "system" object whose entry is // to be removed from the table. // // Return Value : None. // // Pre Conditions : None. // // Post Conditions : Entry is removed from table. // // Side Effects : None. // // Error Conditions : None. // // Notes : None. // //---- END OF MEMBER FUNCTION DEFINITION --------------------------------------- void rmvEntry(Qp0lFID_t srcFID); //---- START OF MEMBER FUNCTION DEFINITION ------------------------------------- // // Member Function Name : getTgtPath // // Function Description : Retrieve the absolute pathname for the object whose // entry's source file ID matches the input one. // // Parameters : // // pathP (output) // Pointer to the buffer to receive the NULL-terminated target pathname. // This space must be at least MAX_PATH_LENGTH bytes long. // // srcFID (input) // Pointer to a FID for the source "system" object whose entry's // target pathname is to be retrieved from the table. // // Return Value : None. // // Pre Conditions : pathP points to at least MAX_PATH_LENGTH available // bytes. // // Post Conditions : pathP's buffer contains the target path. // // Side Effects : None. // // Error Conditions : None. // // Notes : None. // //---- END OF MEMBER FUNCTION DEFINITION --------------------------------------- int getTgtPath(char *pathP, Qp0lFID_t srcFID); private: FIDTableEntry *headP; // Head pointer of linked list. FIDTableEntry *lastP; // Pointer to last element in linked list. FIDTableEntry *nextAvailP; // Pointer to next available space to place the // next entry added with addEntry(). //---- START OF MEMBER FUNCTION DEFINITION ------------------------------------- // // Member Function Name : findEntry // // Function Description : Retrieve a pointer to the entry in the table that // matches the input source file ID. // // Parameters : // // srcFID (input) // Pointer to a FID for the source "system" object whose entry's // target pathname is to be retrieved from the table. // // Return Value : Pointer to the FIDTableEntry that matches, or NULL // if not found. // // Pre Conditions : None. // // Post Conditions : pathP's buffer contains the target path. // // Side Effects : None. // // Error Conditions : None. // // Notes : None. // //---- END OF MEMBER FUNCTION DEFINITION --------------------------------------- FIDTableEntry *findEntry(Qp0lFID_t srcFID); FIDTable(const FIDTable &tbl) {} // Copy constructor. void operator=(const FIDTable &tbl) {} // Assignment operator. // No code. }; // End of FIDTable class. #endif /* _FIDTBL_H */