00001 #ifndef CDBBDB_OBJECT_CLONE_HH 00002 #define CDBBDB_OBJECT_CLONE_HH 00003 00004 // File and Version Information: 00005 // $Id: CdbBdbObjectClone.hh,v 1.4 2004/10/21 20:35:49 gapon Exp $ 00006 00007 #include "CdbBase/CdbCommon.hh" 00008 00009 #include <oo.h> // ooRef(ooObj), ooHandle(ooObj) 00010 00011 // Forward declarations 00012 00013 class CdbBdbObjectCloneUserAction; 00014 class CdbBdbObjectCloneImpl; 00015 00016 /// This class provides "deep clone" facility for persistent objects. 00017 /** 00018 * This facility uses the Objectivity/DB Active Schema API to clone persistent 00019 * objects. 00020 * 00021 * IMPLEMENTATION NOTES: 00022 * 00023 * (1) This class uses PIMPL idiom to protect end users 00024 * of the class from being exposed to the buggy header 00025 * files of the Objectivity/DB Active Schema API. 00026 * 00027 * (2) This class violates CDB API convention on the inclusion 00028 * of "CdbBase/CdbCommon.hh" header file to avoid STD namespace 00029 * conflicts of the kind described above. 00030 */ 00031 class CdbBdbObjectClone { 00032 00033 private: 00034 00035 /// Default constructor (NOT IMPLEMENTED) 00036 /** 00037 * There is no way to get the consistent object's context without user defined 00038 * parameters passed through the normal constructor. 00039 */ 00040 CdbBdbObjectClone( ); 00041 00042 public: 00043 00044 /// Normal constructor 00045 /** 00046 * Sets the initial context for the cloning. This context can be reused 00047 * accross multiple calls to the cloning method itself. 00048 * 00049 * If the hint is not set then it will have to be set before attempting 00050 * to copy. Otherwise the clone method will fail. 00051 * 00052 * The ownership to a user action (if any) does not get transferred 00053 * into the current object. We may need non-const pointer to let a user 00054 * to maintain the context of user action between calls. 00055 * 00056 * Note, a user action object can be overriden by passing another user cation 00057 * object when calling the cloning method. 00058 */ 00059 CdbBdbObjectClone( const ooRef(ooObj)& theHint = 0, 00060 CdbBdbObjectCloneUserAction* theUserAction = 0, 00061 bool deepCopyMode = false, 00062 bool verboseMode = false, 00063 bool debugMode = false ); 00064 00065 /// Destructor 00066 /** 00067 * More details... 00068 */ 00069 virtual ~CdbBdbObjectClone( ); 00070 00071 /// Make a persistent clone of the specified object 00072 /** 00073 * It's guaranteed that the resulting object (if successfull) will be 00074 * different from the output one. It will be placed into the location 00075 * specified through the "hint" parameter passed to the class's constructor. 00076 * 00077 * If the passed object refers other objects either via references or relationships 00078 * and if the "deep clone" flag was passed to the class's constructor then the whole 00079 * network of objects will be copied. Otherwise (if no "deep copy" flag is specified) 00080 * then the resulting composite object will borrow external references/associations 00081 * from the input one. 00082 * 00083 * The operation will return "true" in case of success, it will return "false" 00084 * in case of any errors. 00085 */ 00086 bool clone( const ooHandle(ooObj)& theInputH, 00087 ooHandle(ooObj)& theOutputH ); 00088 /// Set hint 00089 /** 00090 * A valid hint object is expected. Otherwise the code will crash. 00091 * 00092 * The method will return the previous value of the hint. 00093 */ 00094 ooRef(ooObj) setHint( const ooRef(ooObj)& theHint ); 00095 00096 /// Set user action 00097 /** 00098 * If 0 pointer is passed then the current user action will be reset 00099 * and it will not be called anymore. 00100 * 00101 * The method will return a pointer onto the previous action (if any). 00102 * 00103 * @see class CdbBdbObjectCloneUserAction 00104 */ 00105 CdbBdbObjectCloneUserAction* setUserAction( CdbBdbObjectCloneUserAction* theUserAction ); 00106 00107 private: 00108 00109 // Here is my implementation 00110 00111 CdbBdbObjectCloneImpl* _myImpl; 00112 }; 00113 00114 #endif // CDBBDB_OBJECT_CLONE_HH
1.3-rc3