From: apo Date: Fri, 22 Dec 2006 15:43:05 +0000 (+0000) Subject: To provide more general implementation for SALOME_GenericObj. X-Git-Tag: WP1_2_3_25-12-2006_persistent_for_cache~1 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=6da514fc0d340653fac49f01e3173fe43193adc4;p=modules%2Fvisu.git To provide more general implementation for SALOME_GenericObj. --- diff --git a/src/VISUGUI/VisuGUI_CutLinesDlg.h b/src/VISUGUI/VisuGUI_CutLinesDlg.h index 40cc9ede..dfbc28dc 100644 --- a/src/VISUGUI/VisuGUI_CutLinesDlg.h +++ b/src/VISUGUI/VisuGUI_CutLinesDlg.h @@ -37,7 +37,8 @@ class SUIT_ViewManager; class SalomeApp_Module; class VisuGUI_InputPane; -namespace VISU{ +namespace VISU +{ class CutLines_i; } diff --git a/src/VISUGUI/VisuGUI_CutPlanesDlg.cxx b/src/VISUGUI/VisuGUI_CutPlanesDlg.cxx index c092854f..804c545e 100644 --- a/src/VISUGUI/VisuGUI_CutPlanesDlg.cxx +++ b/src/VISUGUI/VisuGUI_CutPlanesDlg.cxx @@ -530,6 +530,9 @@ VisuGUI_CutPlanesDlg::VisuGUI_CutPlanesDlg (SalomeApp_Module* theModule) // this, SLOT(onWindowActivated(SUIT_ViewWindow*))); } +VisuGUI_CutPlanesDlg::~VisuGUI_CutPlanesDlg() +{} + void VisuGUI_CutPlanesDlg::initFromPrsObject (VISU::ColoredPrs3d_i* thePrs, bool theInit) { if( theInit ) diff --git a/src/VISUGUI/VisuGUI_CutPlanesDlg.h b/src/VISUGUI/VisuGUI_CutPlanesDlg.h index 872a267a..e94a7bf6 100644 --- a/src/VISUGUI/VisuGUI_CutPlanesDlg.h +++ b/src/VISUGUI/VisuGUI_CutPlanesDlg.h @@ -30,7 +30,6 @@ #define VISUGUI_CUTPLANESDLG_H #include "VisuGUI_Prs3dDlg.h" -#include "VISU_CutPlanes_i.hh" #include @@ -44,6 +43,11 @@ #include "SALOMEconfig.h" #include CORBA_CLIENT_HEADER(VISU_Gen) +namespace VISU +{ + class CutPlanes_i; +}; + class SUIT_ViewWindow; class SUIT_ViewManager; class SalomeApp_Module; @@ -109,7 +113,7 @@ class VisuGUI_CutPlanesDlg : public VisuGUI_Prs3dDlg public: VisuGUI_CutPlanesDlg (SalomeApp_Module* theModule); - ~VisuGUI_CutPlanesDlg() {}; + ~VisuGUI_CutPlanesDlg(); virtual void initFromPrsObject(VISU::ColoredPrs3d_i* thePrs, bool theInit = true); virtual int storeToPrsObject(VISU::ColoredPrs3d_i* thePrs); diff --git a/src/VISUGUI/VisuGUI_DeformedShapeDlg.cxx b/src/VISUGUI/VisuGUI_DeformedShapeDlg.cxx index 3cd3a6f2..e60b0943 100644 --- a/src/VISUGUI/VisuGUI_DeformedShapeDlg.cxx +++ b/src/VISUGUI/VisuGUI_DeformedShapeDlg.cxx @@ -135,6 +135,9 @@ VisuGUI_DeformedShapeDlg::VisuGUI_DeformedShapeDlg (SalomeApp_Module* theModule) connect(buttonHelp, SIGNAL(clicked()), this, SLOT(onHelp())); } +VisuGUI_DeformedShapeDlg::~VisuGUI_DeformedShapeDlg() +{} + void VisuGUI_DeformedShapeDlg::initFromPrsObject (VISU::ColoredPrs3d_i* thePrs, bool theInit) { if( theInit ) diff --git a/src/VISUGUI/VisuGUI_DeformedShapeDlg.h b/src/VISUGUI/VisuGUI_DeformedShapeDlg.h index 5d77bf71..a832a9db 100644 --- a/src/VISUGUI/VisuGUI_DeformedShapeDlg.h +++ b/src/VISUGUI/VisuGUI_DeformedShapeDlg.h @@ -43,7 +43,8 @@ class SalomeApp_Module; class VisuGUI_InputPane; -namespace VISU{ +namespace VISU +{ class DeformedShape_i; } @@ -53,7 +54,7 @@ class VisuGUI_DeformedShapeDlg : public VisuGUI_Prs3dDlg public: VisuGUI_DeformedShapeDlg (SalomeApp_Module* theModule); - ~VisuGUI_DeformedShapeDlg() {}; + ~VisuGUI_DeformedShapeDlg(); double getFactor() { return ScalFact->value(); } diff --git a/src/VISUGUI/VisuGUI_GaussPointsDlg.cxx b/src/VISUGUI/VisuGUI_GaussPointsDlg.cxx index ce78dfa5..11688a78 100644 --- a/src/VISUGUI/VisuGUI_GaussPointsDlg.cxx +++ b/src/VISUGUI/VisuGUI_GaussPointsDlg.cxx @@ -650,6 +650,9 @@ VisuGUI_GaussPointsDlg::VisuGUI_GaussPointsDlg(SalomeApp_Module* theModule, bool connect( buttonHelp, SIGNAL( clicked() ), this, SLOT( onHelp() ) ); } +VisuGUI_GaussPointsDlg::~VisuGUI_GaussPointsDlg() +{} + void VisuGUI_GaussPointsDlg::initFromPrsObject(VISU::ColoredPrs3d_i* thePrs, bool theInit) { if( theInit ) diff --git a/src/VISUGUI/VisuGUI_GaussPointsDlg.h b/src/VISUGUI/VisuGUI_GaussPointsDlg.h index 592ac66f..bf117d7c 100644 --- a/src/VISUGUI/VisuGUI_GaussPointsDlg.h +++ b/src/VISUGUI/VisuGUI_GaussPointsDlg.h @@ -123,7 +123,7 @@ class VisuGUI_GaussPointsDlg : public VisuGUI_Prs3dDlg public: VisuGUI_GaussPointsDlg (SalomeApp_Module* theModule, bool SetPref = FALSE); - ~VisuGUI_GaussPointsDlg() {} + ~VisuGUI_GaussPointsDlg(); //! Initializing dialog from the Gauss Points presentation. virtual void initFromPrsObject(VISU::ColoredPrs3d_i* thePrs, bool theInit = true); diff --git a/src/VISUGUI/VisuGUI_IsoSurfacesDlg.cxx b/src/VISUGUI/VisuGUI_IsoSurfacesDlg.cxx index 8f218955..c24f76a9 100644 --- a/src/VISUGUI/VisuGUI_IsoSurfacesDlg.cxx +++ b/src/VISUGUI/VisuGUI_IsoSurfacesDlg.cxx @@ -219,6 +219,9 @@ VisuGUI_IsoSurfacesDlg::VisuGUI_IsoSurfacesDlg (SalomeApp_Module* theModule) connect( buttonHelp, SIGNAL( clicked() ), this, SLOT( onHelp() ) ); } +VisuGUI_IsoSurfacesDlg::~VisuGUI_IsoSurfacesDlg() +{} + void VisuGUI_IsoSurfacesDlg::accept() { if (myIsoPane->check() && myScalarPane->check()) diff --git a/src/VISUGUI/VisuGUI_IsoSurfacesDlg.h b/src/VISUGUI/VisuGUI_IsoSurfacesDlg.h index 82c37109..efea4c1e 100644 --- a/src/VISUGUI/VisuGUI_IsoSurfacesDlg.h +++ b/src/VISUGUI/VisuGUI_IsoSurfacesDlg.h @@ -30,7 +30,6 @@ #define VISUGUI_ISOSURFACESDLG_H #include "VisuGUI_Prs3dDlg.h" -#include "VISU_IsoSurfaces_i.hh" #include #include @@ -41,6 +40,11 @@ #include #include +namespace VISU +{ + class IsoSurfaces_i; +}; + class SalomeApp_Module; class VisuGUI_InputPane; @@ -77,7 +81,7 @@ class VisuGUI_IsoSurfacesDlg : public VisuGUI_Prs3dDlg public: VisuGUI_IsoSurfacesDlg (SalomeApp_Module* theModule); - ~VisuGUI_IsoSurfacesDlg() {}; + ~VisuGUI_IsoSurfacesDlg(); virtual void initFromPrsObject(VISU::ColoredPrs3d_i* thePrs, bool theInit = true); virtual int storeToPrsObject(VISU::ColoredPrs3d_i* thePrs); diff --git a/src/VISUGUI/VisuGUI_Plot3DDlg.cxx b/src/VISUGUI/VisuGUI_Plot3DDlg.cxx index afc92def..70099107 100644 --- a/src/VISUGUI/VisuGUI_Plot3DDlg.cxx +++ b/src/VISUGUI/VisuGUI_Plot3DDlg.cxx @@ -254,8 +254,7 @@ VisuGUI_Plot3DPane::VisuGUI_Plot3DPane (QWidget* parent) //purpose : //======================================================================= VisuGUI_Plot3DPane::~VisuGUI_Plot3DPane() -{ -} +{} //======================================================================= //function : storePrsParams @@ -599,6 +598,9 @@ VisuGUI_Plot3DDlg::VisuGUI_Plot3DDlg (SalomeApp_Module* theModule) connect(buttonHelp, SIGNAL(clicked()), this, SLOT(onHelp())); } +VisuGUI_Plot3DDlg::~VisuGUI_Plot3DDlg() +{} + //======================================================================= //function : accept //purpose : diff --git a/src/VISUGUI/VisuGUI_Plot3DDlg.h b/src/VISUGUI/VisuGUI_Plot3DDlg.h index bd49e03c..baee6589 100644 --- a/src/VISUGUI/VisuGUI_Plot3DDlg.h +++ b/src/VISUGUI/VisuGUI_Plot3DDlg.h @@ -31,15 +31,14 @@ #include "VisuGUI_Prs3dDlg.h" -#include "VISU_Plot3D_i.hh" - #include #include class SalomeApp_Module; class VisuGUI_InputPane; -namespace VISU { +namespace VISU +{ class Plot3D_i; }; @@ -103,7 +102,7 @@ class VisuGUI_Plot3DDlg : public VisuGUI_Prs3dDlg public: VisuGUI_Plot3DDlg (SalomeApp_Module* theModule); - ~VisuGUI_Plot3DDlg() {}; + ~VisuGUI_Plot3DDlg(); virtual void initFromPrsObject(VISU::ColoredPrs3d_i* thePrs, bool theInit = true); virtual int storeToPrsObject(VISU::ColoredPrs3d_i* thePrs); diff --git a/src/VISUGUI/VisuGUI_ScalarBarDlg.cxx b/src/VISUGUI/VisuGUI_ScalarBarDlg.cxx index fac87810..8455b972 100644 --- a/src/VISUGUI/VisuGUI_ScalarBarDlg.cxx +++ b/src/VISUGUI/VisuGUI_ScalarBarDlg.cxx @@ -115,6 +115,9 @@ VisuGUI_ScalarBarDlg::VisuGUI_ScalarBarDlg (SalomeApp_Module* theModule, bool Se connect( buttonHelp, SIGNAL( clicked() ), this, SLOT( onHelp() ) ); } +VisuGUI_ScalarBarDlg::~VisuGUI_ScalarBarDlg() +{} + /*! Called when button is clicked, validates data and closes dialog */ diff --git a/src/VISUGUI/VisuGUI_ScalarBarDlg.h b/src/VISUGUI/VisuGUI_ScalarBarDlg.h index f05ee589..56cd2849 100644 --- a/src/VISUGUI/VisuGUI_ScalarBarDlg.h +++ b/src/VISUGUI/VisuGUI_ScalarBarDlg.h @@ -44,17 +44,20 @@ #include "QtxDblSpinBox.h" -#include "VISU_ScalarMap_i.hh" - class VisuGUI_InputPane; +namespace VISU +{ + class ScalarMap_i; +} + class VisuGUI_ScalarBarDlg : public VisuGUI_Prs3dDlg { Q_OBJECT; public: VisuGUI_ScalarBarDlg (SalomeApp_Module* theModule, bool SetPref = FALSE); - ~VisuGUI_ScalarBarDlg() {}; + ~VisuGUI_ScalarBarDlg(); bool isToSave() {return myScalarPane->isToSave();} diff --git a/src/VISUGUI/VisuGUI_ScalarMapOnDeformedShapeDlg.cxx b/src/VISUGUI/VisuGUI_ScalarMapOnDeformedShapeDlg.cxx index 17bfa7bd..8fb375ef 100644 --- a/src/VISUGUI/VisuGUI_ScalarMapOnDeformedShapeDlg.cxx +++ b/src/VISUGUI/VisuGUI_ScalarMapOnDeformedShapeDlg.cxx @@ -163,6 +163,9 @@ VisuGUI_ScalarMapOnDeformedShapeDlg::VisuGUI_ScalarMapOnDeformedShapeDlg (Salome connect(myTimeStampsCombo, SIGNAL(activated(int)), this, SLOT(onTimeStampChanged(int))); } +VisuGUI_ScalarMapOnDeformedShapeDlg::~VisuGUI_ScalarMapOnDeformedShapeDlg() +{} + void VisuGUI_ScalarMapOnDeformedShapeDlg::initFromPrsObject(VISU::ColoredPrs3d_i* thePrs, bool theInit) { if( theInit ) diff --git a/src/VISUGUI/VisuGUI_ScalarMapOnDeformedShapeDlg.h b/src/VISUGUI/VisuGUI_ScalarMapOnDeformedShapeDlg.h index b12c706f..f891508f 100644 --- a/src/VISUGUI/VisuGUI_ScalarMapOnDeformedShapeDlg.h +++ b/src/VISUGUI/VisuGUI_ScalarMapOnDeformedShapeDlg.h @@ -48,7 +48,8 @@ class SalomeApp_Module; class VisuGUI_InputPane; -namespace VISU{ +namespace VISU +{ class ScalarMapOnDeformedShape_i; } @@ -58,7 +59,7 @@ class VisuGUI_ScalarMapOnDeformedShapeDlg : public VisuGUI_Prs3dDlg public: VisuGUI_ScalarMapOnDeformedShapeDlg (SalomeApp_Module* theModule); - ~VisuGUI_ScalarMapOnDeformedShapeDlg() {}; + ~VisuGUI_ScalarMapOnDeformedShapeDlg(); double getFactor() { return ScalFact->value(); } diff --git a/src/VISUGUI/VisuGUI_StreamLinesDlg.cxx b/src/VISUGUI/VisuGUI_StreamLinesDlg.cxx index c63ae9d9..6ed2d978 100644 --- a/src/VISUGUI/VisuGUI_StreamLinesDlg.cxx +++ b/src/VISUGUI/VisuGUI_StreamLinesDlg.cxx @@ -312,6 +312,8 @@ VisuGUI_StreamLinesDlg::VisuGUI_StreamLinesDlg (SalomeApp_Module* theModule) enableSetColor(); } +VisuGUI_StreamLinesDlg::~VisuGUI_StreamLinesDlg() +{} void VisuGUI_StreamLinesDlg::initFromPrsObject (VISU::ColoredPrs3d_i* thePrs, bool theInit) { diff --git a/src/VISUGUI/VisuGUI_StreamLinesDlg.h b/src/VISUGUI/VisuGUI_StreamLinesDlg.h index 11b68a37..1d67efd1 100644 --- a/src/VISUGUI/VisuGUI_StreamLinesDlg.h +++ b/src/VISUGUI/VisuGUI_StreamLinesDlg.h @@ -38,7 +38,8 @@ class SalomeApp_Module; class VisuGUI_InputPane; class QtxDblSpinBox; -namespace VISU{ +namespace VISU +{ class StreamLines_i; } @@ -47,7 +48,7 @@ class VisuGUI_StreamLinesDlg: public VisuGUI_Prs3dDlg Q_OBJECT public: VisuGUI_StreamLinesDlg (SalomeApp_Module* theModule); - ~VisuGUI_StreamLinesDlg() {}; + ~VisuGUI_StreamLinesDlg(); virtual void initFromPrsObject(VISU::ColoredPrs3d_i* thePrs, bool theInit = true); virtual int storeToPrsObject(VISU::ColoredPrs3d_i* thePrs); diff --git a/src/VISUGUI/VisuGUI_VectorsDlg.cxx b/src/VISUGUI/VisuGUI_VectorsDlg.cxx index 03323bff..11331d55 100644 --- a/src/VISUGUI/VisuGUI_VectorsDlg.cxx +++ b/src/VISUGUI/VisuGUI_VectorsDlg.cxx @@ -199,7 +199,8 @@ VisuGUI_VectorsDlg::VisuGUI_VectorsDlg (SalomeApp_Module* theModule) enableSetColor(); } - +VisuGUI_VectorsDlg::~VisuGUI_VectorsDlg() +{} void VisuGUI_VectorsDlg::initFromPrsObject(VISU::ColoredPrs3d_i* thePrs, bool theInit) { if( theInit ) diff --git a/src/VISUGUI/VisuGUI_VectorsDlg.h b/src/VISUGUI/VisuGUI_VectorsDlg.h index 916eea75..829747fc 100644 --- a/src/VISUGUI/VisuGUI_VectorsDlg.h +++ b/src/VISUGUI/VisuGUI_VectorsDlg.h @@ -48,7 +48,8 @@ class SalomeApp_Module; class VisuGUI_InputPane; -namespace VISU{ +namespace VISU +{ class Vectors_i; } @@ -58,7 +59,7 @@ class VisuGUI_VectorsDlg : public VisuGUI_Prs3dDlg public: VisuGUI_VectorsDlg (SalomeApp_Module* theModule); - ~VisuGUI_VectorsDlg() {}; + ~VisuGUI_VectorsDlg(); void setScaleFactor( double sf ); double getScaleFactor(); diff --git a/src/VISU_I/SALOME_GenericObjPointer.cc b/src/VISU_I/SALOME_GenericObjPointer.cc index 384f6481..1e774e1e 100644 --- a/src/VISU_I/SALOME_GenericObjPointer.cc +++ b/src/VISU_I/SALOME_GenericObjPointer.cc @@ -23,104 +23,3 @@ // Module : SALOME #include "SALOME_GenericObjPointer.hh" - -using namespace SALOME; - -//---------------------------------------------------------------------------- -GenericObjPtrBase -::GenericObjPtrBase() : - Object(0) -{ - // Add a reference to the object. - this->Register(); -} - -//---------------------------------------------------------------------------- -GenericObjPtrBase -::GenericObjPtrBase(GenericObj_i* r): - Object(r) -{ - // Add a reference to the object. - this->Register(); -} - -//---------------------------------------------------------------------------- -GenericObjPtrBase -::GenericObjPtrBase(const GenericObjPtrBase& r): - Object(r.Object) -{ - // Add a reference to the object. - this->Register(); -} - -//---------------------------------------------------------------------------- -GenericObjPtrBase -::GenericObjPtrBase(GenericObj_i* r, const GenericObjPtrBase::NoReference&): - Object(r) -{ - // Do not add a reference to the object because we received the - // NoReference argument. -} - -//---------------------------------------------------------------------------- -GenericObjPtrBase -::~GenericObjPtrBase() -{ - // The main pointer must be set to NULL before calling UnRegister, - // so use a local variable to save the pointer. This is because the - // garbage collection reference graph traversal may make it back to - // this smart pointer, and we do not want to include this reference. - if(GenericObj_i* object = this->Object) - { - this->Object = 0; - object->Destroy(); - } -} - -//---------------------------------------------------------------------------- -GenericObjPtrBase& -GenericObjPtrBase -::operator=(GenericObj_i* r) -{ - // This is an exception-safe assignment idiom that also gives the - // correct order of register/unregister calls to all objects - // involved. A temporary is constructed that references the new - // object. Then the main pointer and temporary are swapped and the - // temporary's destructor unreferences the old object. - GenericObjPtrBase(r).Swap(*this); - return *this; -} - -//---------------------------------------------------------------------------- -GenericObjPtrBase& -GenericObjPtrBase -::operator=(const GenericObjPtrBase& r) -{ - // This is an exception-safe assignment idiom that also gives the - // correct order of register/unregister calls to all objects - // involved. A temporary is constructed that references the new - // object. Then the main pointer and temporary are swapped and the - // temporary's destructor unreferences the old object. - GenericObjPtrBase(r).Swap(*this); - return *this; -} - -//---------------------------------------------------------------------------- -void GenericObjPtrBase -::Swap(GenericObjPtrBase& r) -{ - // Just swap the pointers. This is used internally by the - // assignment operator. - GenericObj_i* temp = r.Object; - r.Object = this->Object; - this->Object = temp; -} - -//---------------------------------------------------------------------------- -void GenericObjPtrBase -::Register() -{ - // Add a reference only if the object is not NULL. - if(this->Object) - this->Object->Register(); -} diff --git a/src/VISU_I/SALOME_GenericObjPointer.hh b/src/VISU_I/SALOME_GenericObjPointer.hh index 4e1bf06a..e710a4f0 100644 --- a/src/VISU_I/SALOME_GenericObjPointer.hh +++ b/src/VISU_I/SALOME_GenericObjPointer.hh @@ -25,132 +25,157 @@ #ifndef SALOME_GenericObjPointer_HH #define SALOME_GenericObjPointer_HH -#include "SALOME_GenericObj_i.hh" +#include "SALOMEconfig.h" +#include CORBA_SERVER_HEADER(SALOME_GenericObj) + +#include // for std::basic_ostream namespace SALOME { - class GenericObjPtrBase + //---------------------------------------------------------------------------- + template + class GenericObjPtr { - public: - // Description: - // Initialize smart pointer to NULL. - GenericObjPtrBase(); - - // Description: - // Initialize smart pointer to given object. - GenericObjPtrBase( GenericObj_i* ); - - // Description: - // Initialize smart pointer with a new reference to the same object - // referenced by given smart pointer. - GenericObjPtrBase( const GenericObjPtrBase& ); - - // Description: - // Destroy smart pointer and remove the reference to its object. - ~GenericObjPtrBase(); - - // Description: - // Assign object to reference. This removes any reference to an old object. - GenericObjPtrBase& operator=( GenericObj_i* ); - GenericObjPtrBase& operator=( const GenericObjPtrBase& ); - - // Description: - // Get the contained pointer. - GenericObj_i* GetPointer() const + //! Pointer to the actual object. + TGenericObj* myPointer; + + void + swap(GenericObjPtr& thePointer) { - return this->Object; + TGenericObj* aPointer = thePointer.myPointer; + thePointer.myPointer = this->myPointer; + this->myPointer = aPointer; } - protected: - // Initialize smart pointer to given object, but do not increment - // reference count. The destructor will still decrement the count. - // This effectively makes it an auto-ptr. - class NoReference {}; - GenericObjPtrBase(GenericObj_i* r, const NoReference&); - - // Pointer to the actual object. - GenericObj_i* Object; + void + Register() + { + if(this->myPointer) + this->myPointer->Register(); + } - private: - // Internal utility methods. - void Swap( GenericObjPtrBase& ); - void Register(); - }; + void + Destroy() + { + if(this->myPointer){ + this->myPointer->Destroy(); + this->myPointer = NULL; + } + } - template - class GenericObjPtr: public GenericObjPtrBase - { public: - // Description: - // Initialize smart pointer to NULL. - GenericObjPtr() {} - - // Description: - // Initialize smart pointer to given object. - GenericObjPtr(T* r): GenericObjPtrBase(r) {} - - // Description: - // Initialize smart pointer with a new reference to the same object - // referenced by given smart pointer. - GenericObjPtr(const GenericObjPtrBase& r): GenericObjPtrBase(r) {} - - // Description: - // Assign object to reference. This removes any reference to an old - // object. - GenericObjPtr& operator=(T* r) + //! Initialize smart pointer to NULL. + GenericObjPtr(): + myPointer(NULL) + {} + + //! Initialize smart pointer to given object (TSGenericObj must be complete). + template + explicit + GenericObjPtr(TSGenericObj* thePointer): + myPointer(thePointer) { - this->GenericObjPtrBase::operator=(r); - return *this; + this->Register(); + } + + /*! + Initialize smart pointer with a new reference to the same object + referenced by given smart pointer. + */ + GenericObjPtr(const GenericObjPtr& thePointer): + myPointer(thePointer.myPointer) + { + this->Register(); + } + + //! Destroy smart pointer and remove the reference to its object. + ~GenericObjPtr() + { + this->Destroy(); } - // Description: - // Assign object to reference. This removes any reference to an old - // object. - GenericObjPtr& operator=(const GenericObjPtrBase& r) + /*! + Assign object to reference. This removes any reference to an old + object. + */ + GenericObjPtr& + operator=(TGenericObj* thePointer) { - this->GenericObjPtrBase::operator=(r); + GenericObjPtr(thePointer).swap(*this); return *this; } - // Description: - // Get the contained pointer. - T* GetPointer() const + /*! + Assign object to reference. This removes any reference to an old + object. + */ + GenericObjPtr& + operator=(const GenericObjPtr& thePointer) { - return dynamic_cast(this->Object); + GenericObjPtr(thePointer).swap(*this); + return *this; } - // Description: - // Get the contained pointer. - operator T* () const + //! Get the contained pointer. + virtual + TGenericObj* + get() const { - return dynamic_cast(this->Object); + return this->myPointer; } - // Description: - // Dereference the pointer and return a reference to the contained - // object. - T& operator*() const + //! Get the contained pointer. + operator TGenericObj* () const { - return *dynamic_cast(this->Object); + return this->get(); } - // Description: - // Provides normal pointer target member access using operator ->. - T* operator->() const + /*! + Dereference the pointer and return a reference to the contained + object. + */ + TGenericObj& + operator*() const { - return dynamic_cast(this->Object); + return *this->get(); } - // Description: - // Create an instance of an object. - static GenericObjPtr New() + //! Provides normal pointer target member access using operator ->. + TGenericObj* operator->() const { - return GenericObjPtr(T::New(), NoReference()); + return this->get(); } - protected: - GenericObjPtr(T* r, const NoReference& n): GenericObjPtrBase(r, n) {} + operator bool () const + { + return this->get() != 0; + } }; } +template +inline +bool +operator==(SALOME::GenericObjPtr const & a, SALOME::GenericObjPtr const & b) +{ + return a.get() == b.get(); +} + +template +inline +bool +operator!=(SALOME::GenericObjPtr const & a, SALOME::GenericObjPtr const & b) +{ + return a.get() != b.get(); +} + +template +std::ostream& +operator<< (std::ostream & os, SALOME::GenericObjPtr const & p) +{ + os << p.get(); + return os; +} + + #endif diff --git a/src/VISU_I/VISU_ColoredPrs3dCache_i.cc b/src/VISU_I/VISU_ColoredPrs3dCache_i.cc index 3671bd28..3cbde11a 100644 --- a/src/VISU_I/VISU_ColoredPrs3dCache_i.cc +++ b/src/VISU_I/VISU_ColoredPrs3dCache_i.cc @@ -93,7 +93,7 @@ namespace return aPrs3d; } } - return NULL; + return VISU::TPrs3dPtr(); } @@ -105,7 +105,7 @@ namespace const size_t theRawEstimatedMemorySize) { VISU::TPrs3dPtr aPrs3d = FindSameFieldPrs(theHolderMap, theInput, theType); - if(aPrs3d.GetPointer()) + if(aPrs3d) return aPrs3d->GetMemorySize(); return CORBA::Float(theRawEstimatedMemorySize/(1024.0*1024.0)); // convert to Mb } @@ -191,7 +191,7 @@ namespace VISU::TLastVisitedPrsList::iterator aEndIter = thePrsList.end(); for(; anIter != aEndIter; anIter++){ VISU::TPrs3dPtr aPrs3d = *anIter; - if(aPrs3d.GetPointer() == thePrs3d.GetPointer()) + if(aPrs3d == thePrs3d) thePrsList.erase(anIter); } } @@ -430,11 +430,10 @@ VISU::ColoredPrs3dCache_i ::RegisterInHolder(VISU::ColoredPrs3d_i* thePrs3d, const std::string& theHolderEntry) { - TPrs3dPtr aPrs3d( thePrs3d ); - thePrs3d->Destroy(); - - thePrs3d->SetHolderEntry( theHolderEntry ); + TPrs3dPtr aPrs3d(thePrs3d); myHolderMap[theHolderEntry].push_front(aPrs3d); + thePrs3d->SetHolderEntry( theHolderEntry ); + thePrs3d->Destroy(); return thePrs3d; } @@ -465,11 +464,10 @@ VISU::TPrs3dPtr VISU::ColoredPrs3dCache_i ::GetLastVisitedPrs(VISU::ColoredPrs3dHolder_i* theHolder) { - TLastVisitedPrsList aList = GetLastVisitedPrsList(theHolder); + const TLastVisitedPrsList& aList = GetLastVisitedPrsList(theHolder); if( !aList.empty() ) return aList.front(); - - return NULL; + return VISU::TPrs3dPtr(); } @@ -489,7 +487,7 @@ VISU::ColoredPrs3dCache_i return aPrs3d; } } - return NULL; + return VISU::TPrs3dPtr(); } @@ -509,7 +507,7 @@ VISU::ColoredPrs3dCache_i std::string aHolderEntry = theHolder->GetEntry(); VISU::VISUType aPrsType = theHolder->GetPrsType(); CORBA::Float aRequiredMemory = 0.0; - if(aPrs3d.GetPointer()){ + if(aPrs3d){ aLastVisitedPrsList.push_front(aPrs3d); if(MYDEBUG) cout << "FindPrsByInput " << aPrs3d << endl; }else if(anIsCheckPossible && IsPossible(aPrsType, theInput, aRequiredMemory, aHolderEntry)){ @@ -631,7 +629,7 @@ VISU::ColoredPrs3dCache_i for(; aPrsIter != aPrsIterEnd; aPrsIter++) if(TPrs3dPtr aPrs3d = *aPrsIter) { - cout << aPrs3d.GetPointer() << " (" << aPrs3d->GetMemorySize() << " Mb)"; + cout << aPrs3d << " (" << aPrs3d->GetMemorySize() << " Mb)"; if(aPrsIter == aPrsList.begin()) cout << " (device)"; cout << endl; diff --git a/src/VISU_I/VISU_ColoredPrs3dCache_i.hh b/src/VISU_I/VISU_ColoredPrs3dCache_i.hh index 41fc4b3f..2ba3cda7 100644 --- a/src/VISU_I/VISU_ColoredPrs3dCache_i.hh +++ b/src/VISU_I/VISU_ColoredPrs3dCache_i.hh @@ -40,32 +40,57 @@ namespace VISU struct TPrs3dPtr: SALOME::GenericObjPtr { typedef SALOME::GenericObjPtr TSuperClass; - //! Initialize smart pointer to given object. - TPrs3dPtr(ColoredPrs3d_i* r): TSuperClass(r) {} - - //! Initialize smart pointer with a new reference to the same object - // referenced by given smart pointer. - TPrs3dPtr(const SALOME::GenericObjPtrBase& r): TSuperClass(r) {} - - //! Get the contained pointer. - ColoredPrs3d_i* GetPointer() const + + //! Initialize smart pointer to NULL. + TPrs3dPtr(): + TSuperClass() + {} + + //! Initialize smart pointer to given object (TSGenericObj must be complete). + TPrs3dPtr(ColoredPrs3d_i* thePointer): + TSuperClass(thePointer) + {} + + /*! + Initialize smart pointer with a new reference to the same object + referenced by given smart pointer. + */ + TPrs3dPtr(const TPrs3dPtr& thePointer): + TSuperClass(thePointer) + {} + + + /*! + Assign object to reference. This removes any reference to an old + object. + */ + TPrs3dPtr& + operator=(const TPrs3dPtr& thePointer) { - ColoredPrs3d_i* aColoredPrs3d = TSuperClass::GetPointer(); - // To implement postponed restoring of the presentation - aColoredPrs3d->InitFromRestoringState(); - return aColoredPrs3d; + TSuperClass::operator=(thePointer); + return *this; } - //! Get the contained pointer. - operator ColoredPrs3d_i* () const + /*! + Assign object to reference. This removes any reference to an old + object. + */ + TPrs3dPtr& + operator=(ColoredPrs3d_i* thePointer) { - return this->GetPointer(); + TSuperClass::operator=(thePointer); + return *this; } - //! Provides normal pointer target member access using operator ->. - ColoredPrs3d_i* operator->() const + //! Get the contained pointer. + ColoredPrs3d_i* + get() const { - return this->GetPointer(); + ColoredPrs3d_i* aColoredPrs3d = TSuperClass::get(); + // To implement postponed restoring of the presentation + if(aColoredPrs3d) + aColoredPrs3d->InitFromRestoringState(); + return aColoredPrs3d; } }; diff --git a/src/VISU_I/VISU_Prs3d_i.cc b/src/VISU_I/VISU_Prs3d_i.cc index 887a7717..21c28e59 100644 --- a/src/VISU_I/VISU_Prs3d_i.cc +++ b/src/VISU_I/VISU_Prs3d_i.cc @@ -102,7 +102,7 @@ void VISU::Prs3d_i ::OnRestoreInput() { - SetCResult(myPreviousResult.GetPointer()); + SetCResult(myPreviousResult); myMeshName = myPreviousMeshName; } @@ -168,7 +168,7 @@ VISU::Result_i* VISU::Prs3d_i ::GetCResult() const { - return myResult.GetPointer(); + return myResult; } diff --git a/src/VISU_I/VISU_Prs3d_i.hh b/src/VISU_I/VISU_Prs3d_i.hh index 11cf5dab..45805438 100644 --- a/src/VISU_I/VISU_Prs3d_i.hh +++ b/src/VISU_I/VISU_Prs3d_i.hh @@ -32,7 +32,7 @@ #include "VISU_ActorFactory.h" #include "VISU_ConvertorDef.hxx" -#include "SALOME_GenericObj.hh" +#include "SALOME_GenericObj_i.hh" #include "SALOME_GenericObjPointer.hh" #include "SALOME_InteractiveObject.hxx"