Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members  

CdbBdbObjectVisitor.hh

Go to the documentation of this file.
00001 #ifndef CDBBDB_OBJECT_VISITOR_HH
00002 #define CDBBDB_OBJECT_VISITOR_HH
00003 
00004 // File and Version Information:
00005 //      $Id: CdbBdbObjectVisitor.hh,v 1.2 2004/10/21 20:35:50 gapon Exp $
00006 
00007 #include "CdbBase/CdbCommon.hh"
00008 
00009 #include <oo.h>     // ooRef(ooObj), ooHandle(ooObj)
00010 
00011 // Forward declarations
00012 
00013 class CdbBdbObjectVisitorUserAction;
00014 class CdbBdbObjectVisitorImpl;
00015 
00016 /// This class provides "object visitor" facility for persistent objects.
00017 /**
00018   * This facility uses the Objectivity/DB Active Schema API to navigate accross
00019   * an arbitrary graph of objects by visiting each node and calling a user defined
00020   * action at each node. Each node is visited just once. A user defined action object
00021   * provides a feedback wether the visiting should propagate beyond a visited
00022   * node or it should stop at this node or it should break visiting due to a error.
00023   * 
00024   * IMPLEMENTATION NOTES:
00025   *
00026   *   (1) This class uses PIMPL idiom to protect end users
00027   *       of the class from being exposed to the buggy header
00028   *       files of the Objectivity/DB Active Schema API.
00029   *
00030   *   (2) This class violates CDB API convention on the inclusion
00031   *       of "CdbBase/CdbCommon.hh" header file to avoid STD namespace
00032   *       conflicts of the kind described above.
00033   *
00034   * ATTENTION:
00035   *
00036   *   - This group of classes has nothing in common with the famous "Visitor"
00037   *     pattern ("Go4").
00038   */
00039 class CdbBdbObjectVisitor {
00040 
00041 private:
00042 
00043   /// Default constructor (NOT IMPLEMENTED)
00044   /**
00045     * There is no way to get the consistent object's context without user defined
00046     * parameters passed through the normal constructor.
00047     */
00048     CdbBdbObjectVisitor( );
00049 
00050 public:
00051 
00052   /// Normal constructor
00053   /**
00054     * Sets the initial context for the visiting. This context can be reused
00055     * accross multiple calls to the visiting method itself.
00056     *
00057     * A non-zero pointer onto a user defined action is required.
00058     *
00059     * The ownership to a user action does not get transferred
00060     * into the current object. We may need non-const pointer to let a user
00061     * to maintain the context of user action between calls.
00062     *
00063     * Note, a user action object can be overriden by passing another user action
00064     * object by calling a special "setUserAction" method.
00065     */
00066     CdbBdbObjectVisitor( CdbBdbObjectVisitorUserAction* theUserAction,
00067                                                    bool verboseMode = false,
00068                                                    bool debugMode   = false );
00069 
00070   /// Destructor
00071   /**
00072     * More details...
00073     */
00074     virtual ~CdbBdbObjectVisitor( );
00075 
00076   /// Visit the specified object
00077   /**
00078     * The operation will return "true" in case of success, it will return "false"
00079     * in case of any errors.
00080     */
00081     bool visit( const ooHandle(ooObj)& theInputH );
00082 
00083   /// Set user action
00084   /**
00085     * If 0 pointer is passed then the current user action will be reset
00086     * and it will not be called anymore.
00087     *
00088     * The method will return a pointer onto the previous action (if any).
00089     *
00090     * @see class CdbBdbObjectVisitorUserAction
00091     */
00092     CdbBdbObjectVisitorUserAction* setUserAction( CdbBdbObjectVisitorUserAction* theUserAction );
00093 
00094 private:
00095 
00096   // Here is my implementation
00097 
00098     CdbBdbObjectVisitorImpl* _myImpl;
00099 };
00100 
00101 #endif  // CDBBDB_OBJECT_VISITOR_HH

Generated on Mon Dec 5 18:22:00 2005 for CDB by doxygen1.3-rc3