From: mpv Date: Thu, 10 Apr 2014 13:59:01 +0000 (+0400) Subject: Minor changes with classes renaming and virtual destructors declarations. X-Git-Tag: V_0.1~21^2 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=0e2657c401cfc2297fba4f1d799eaf14da193318;p=modules%2Fshaper.git Minor changes with classes renaming and virtual destructors declarations. --- diff --git a/src/Model/Model_Data.h b/src/Model/Model_Data.h index b634d935a..d33819a8f 100644 --- a/src/Model/Model_Data.h +++ b/src/Model/Model_Data.h @@ -6,7 +6,7 @@ #define Model_Data_HeaderFile #include "Model.h" -#include +#include #include #include @@ -19,7 +19,7 @@ class ModelAPI_Attribute; * to get/set attributes from the document and compute result of an operation. */ -class Model_Data: public ModelAPI_Object +class Model_Data: public ModelAPI_Data { TDF_Label myLab; ///< label of the feature in the document /// All attributes of the object identified by the attribute ID diff --git a/src/ModelAPI/CMakeLists.txt b/src/ModelAPI/CMakeLists.txt index c9afbc7ab..4b15c44e3 100644 --- a/src/ModelAPI/CMakeLists.txt +++ b/src/ModelAPI/CMakeLists.txt @@ -6,12 +6,11 @@ INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}) SET(PROJECT_HEADERS ModelAPI.h - ModelAPI_Interface.h ModelAPI_PluginManager.h ModelAPI_Plugin.h ModelAPI_Feature.h ModelAPI_Iterator.h - ModelAPI_Object.h + ModelAPI_Data.h ModelAPI_Document.h ModelAPI_Attribute.h ModelAPI_AttributeDouble.h diff --git a/src/ModelAPI/ModelAPI.i b/src/ModelAPI/ModelAPI.i index 96d4414a9..c0bcc3221 100644 --- a/src/ModelAPI/ModelAPI.i +++ b/src/ModelAPI/ModelAPI.i @@ -5,7 +5,7 @@ #include "ModelAPI_Document.h" #include "ModelAPI_PluginManager.h" #include "ModelAPI_Feature.h" - #include "ModelAPI_Object.h" + #include "ModelAPI_Data.h" #include "ModelAPI_Attribute.h" #include "ModelAPI_AttributeDocRef.h" #include "ModelAPI_AttributeDouble.h" @@ -25,7 +25,7 @@ %shared_ptr(ModelAPI_Document) %shared_ptr(ModelAPI_PluginManager) %shared_ptr(ModelAPI_Feature) -%shared_ptr(ModelAPI_Object) +%shared_ptr(ModelAPI_Data) %shared_ptr(ModelAPI_Attribute) %shared_ptr(ModelAPI_AttributeDocRef) %shared_ptr(ModelAPI_AttributeDouble) @@ -35,7 +35,7 @@ %include "ModelAPI_Document.h" %include "ModelAPI_PluginManager.h" %include "ModelAPI_Feature.h" -%include "ModelAPI_Object.h" +%include "ModelAPI_Data.h" %include "ModelAPI_Attribute.h" %include "ModelAPI_AttributeDocRef.h" %include "ModelAPI_AttributeDouble.h" diff --git a/src/ModelAPI/ModelAPI_Attribute.h b/src/ModelAPI/ModelAPI_Attribute.h index cd7d36a54..1d4bf15e8 100644 --- a/src/ModelAPI/ModelAPI_Attribute.h +++ b/src/ModelAPI/ModelAPI_Attribute.h @@ -20,10 +20,13 @@ public: /// Returns the type of this class of attributes, not static method virtual std::string attributeType() = 0; + /// To virtually destroy the fields of successors + virtual ~ModelAPI_Attribute() {} + protected: /// Objects are created for features automatically - ModelAPI_Attribute() - {} + ModelAPI_Attribute(){} + }; #endif diff --git a/src/ModelAPI/ModelAPI_AttributeDocRef.h b/src/ModelAPI/ModelAPI_AttributeDocRef.h index e9a602dcc..9b0a6c295 100644 --- a/src/ModelAPI/ModelAPI_AttributeDocRef.h +++ b/src/ModelAPI/ModelAPI_AttributeDocRef.h @@ -28,6 +28,9 @@ public: /// Returns the type of this class of attributes, not static method virtual std::string attributeType() {return type();} + /// To virtually destroy the fields of successors + virtual ~ModelAPI_AttributeDocRef() {} + protected: /// Objects are created for features automatically ModelAPI_AttributeDocRef() diff --git a/src/ModelAPI/ModelAPI_AttributeDouble.h b/src/ModelAPI/ModelAPI_AttributeDouble.h index cc6a2dd26..024da5ea5 100644 --- a/src/ModelAPI/ModelAPI_AttributeDouble.h +++ b/src/ModelAPI/ModelAPI_AttributeDouble.h @@ -27,6 +27,9 @@ public: /// Returns the type of this class of attributes, not static method virtual std::string attributeType() {return type();} + /// To virtually destroy the fields of successors + virtual ~ModelAPI_AttributeDouble() {} + protected: /// Objects are created for features automatically ModelAPI_AttributeDouble() diff --git a/src/ModelAPI/ModelAPI_Data.h b/src/ModelAPI/ModelAPI_Data.h new file mode 100644 index 000000000..c8f006ea5 --- /dev/null +++ b/src/ModelAPI/ModelAPI_Data.h @@ -0,0 +1,55 @@ +// File: ModelAPI_Data.hxx +// Created: 21 Mar 2014 +// Author: Mikhail PONIKAROV + +#ifndef ModelAPI_Data_HeaderFile +#define ModelAPI_Data_HeaderFile + +#include "ModelAPI.h" +#include +#include + +class ModelAPI_AttributeDocRef; +class ModelAPI_AttributeDouble; +class ModelAPI_Document; + +/**\class ModelAPI_Data + * \ingroup DataModel + * \brief General object of the application that allows + * to get/set attributes from the document and compute result of an operation. + */ + +class MODELAPI_EXPORT ModelAPI_Data +{ +public: + + /// Returns the name of the feature visible by the user in the object browser + virtual std::string getName() = 0; + + /// Defines the name of the feature visible by the user in the object browser + virtual void setName(std::string theName) = 0; + + /// Returns the attribute that references to another document + virtual std::shared_ptr docRef(const std::string theID) = 0; + /// Returns the attribute that contains real value with double precision + virtual std::shared_ptr real(const std::string theID) = 0; + + /// Initializes object by the attributes: must be called just after the object is created + /// for each attribute of the object + /// \param theID identifier of the attribute that can be referenced by this ID later + /// \param theAttrType type of the created attribute (received from the type method) + virtual void addAttribute(std::string theID, std::string theAttrType) = 0; + + /// Returns the document of this data + virtual std::shared_ptr document() = 0; + + /// To virtually destroy the fields of successors + virtual ~ModelAPI_Data() {} + +protected: + /// Objects are created for features automatically + ModelAPI_Data() + {} +}; + +#endif diff --git a/src/ModelAPI/ModelAPI_Document.h b/src/ModelAPI/ModelAPI_Document.h index 50209d63e..546c5020a 100644 --- a/src/ModelAPI/ModelAPI_Document.h +++ b/src/ModelAPI/ModelAPI_Document.h @@ -90,6 +90,9 @@ public: ///! Returns the vector of groups already added to the document MODELAPI_EXPORT virtual const std::vector& getGroups() const = 0; + /// To virtually destroy the fields of successors + virtual ~ModelAPI_Document() {} + protected: /// Only for SWIG wrapping it is here MODELAPI_EXPORT ModelAPI_Document() diff --git a/src/ModelAPI/ModelAPI_Feature.h b/src/ModelAPI/ModelAPI_Feature.h index 1b166b600..7cb9256a0 100644 --- a/src/ModelAPI/ModelAPI_Feature.h +++ b/src/ModelAPI/ModelAPI_Feature.h @@ -11,7 +11,7 @@ #include #include -class ModelAPI_Object; +class ModelAPI_Data; class ModelAPI_Document; /**\class ModelAPI_Feature @@ -21,7 +21,7 @@ class ModelAPI_Document; */ class ModelAPI_Feature { - std::shared_ptr myData; ///< manager of the data model of a feature + std::shared_ptr myData; ///< manager of the data model of a feature public: /// Returns the kind of a feature (like "Point") @@ -37,13 +37,16 @@ public: MODELAPI_EXPORT virtual void execute() = 0; /// Returns the data manager of this feature - MODELAPI_EXPORT virtual std::shared_ptr data() {return myData;} + MODELAPI_EXPORT virtual std::shared_ptr data() {return myData;} /// Must return document where the new feature must be added to /// By default it is current document MODELAPI_EXPORT virtual std::shared_ptr documentToAdd() {return ModelAPI_PluginManager::get()->currentDocument();} + /// To virtually destroy the fields of successors + virtual ~ModelAPI_Feature() {} + protected: /// Use plugin manager for features creation: this method is /// defined here only for SWIG-wrapping @@ -51,7 +54,7 @@ protected: {} /// Sets the data manager of an object (document does) - MODELAPI_EXPORT void setData(std::shared_ptr theData) {myData = theData;} + MODELAPI_EXPORT void setData(std::shared_ptr theData) {myData = theData;} friend class Model_Document; }; diff --git a/src/ModelAPI/ModelAPI_Interface.h b/src/ModelAPI/ModelAPI_Interface.h deleted file mode 100644 index 8535be86e..000000000 --- a/src/ModelAPI/ModelAPI_Interface.h +++ /dev/null @@ -1,47 +0,0 @@ -// File: ModelAPI_Interface.hxx -// Created: 20 Mar 2014 -// Author: Mikhail PONIKAROV - -#ifndef ModelAPI_Interface_HeaderFile -#define ModelAPI_Interface_HeaderFile - -#include - -/**\class ModelAPI_Interface - * \ingroup DataModel - * \brief General base class for all interfaces in this package - */ - -class MODELAPI_EXPORT ModelAPI_Interface -{ - void* myImpl; ///< pointer to the internal implementation object - -public: - /// None - constructor - virtual ModelAPI_Interface() - { - myImpl = 0; - } - - /// Constructor by the implementation pointer (used for internal needs) - virtual ModelAPI_Interface(void* theImpl) - { - myImpl = theImpl; - } - - /// Copy-constructor - virtual ModelAPI_Interface(ModelAPI_Interface& theOrig) - { - myImpl = theOrig.theImpl; - Duplicate(); - } - - virtual ModelAPI_Interface& operator=(ModelAPI_Interface& const theOrig) - { myImpl = theOrig.theImpl; Duplicate(); return *this;} - - /// Duplicates the objet pointed by myImpl (loosing the old one) - virtual void Duplicate() = 0; - -}; - -#endif diff --git a/src/ModelAPI/ModelAPI_Iterator.h b/src/ModelAPI/ModelAPI_Iterator.h index 73187982f..41032c2fb 100644 --- a/src/ModelAPI/ModelAPI_Iterator.h +++ b/src/ModelAPI/ModelAPI_Iterator.h @@ -38,6 +38,9 @@ public: /// \returns true if given feature equals to the current one virtual bool is(std::shared_ptr theFeature) = 0; + /// To virtually destroy the fields of successors + virtual ~ModelAPI_Iterator() {} + protected: /// Use plugin manager for features creation: this method is /// defined here only for SWIG-wrapping diff --git a/src/ModelAPI/ModelAPI_Object.h b/src/ModelAPI/ModelAPI_Object.h deleted file mode 100644 index cf81f99bf..000000000 --- a/src/ModelAPI/ModelAPI_Object.h +++ /dev/null @@ -1,52 +0,0 @@ -// File: ModelAPI_Object.hxx -// Created: 21 Mar 2014 -// Author: Mikhail PONIKAROV - -#ifndef ModelAPI_Object_HeaderFile -#define ModelAPI_Object_HeaderFile - -#include "ModelAPI.h" -#include -#include - -class ModelAPI_AttributeDocRef; -class ModelAPI_AttributeDouble; -class ModelAPI_Document; - -/**\class ModelAPI_Object - * \ingroup DataModel - * \brief General object of the application that allows - * to get/set attributes from the document and compute result of an operation. - */ - -class MODELAPI_EXPORT ModelAPI_Object -{ -public: - - /// Returns the name of the feature visible by the user in the object browser - virtual std::string getName() = 0; - - /// Defines the name of the feature visible by the user in the object browser - virtual void setName(std::string theName) = 0; - - /// Returns the attribute that references to another document - virtual std::shared_ptr docRef(const std::string theID) = 0; - /// Returns the attribute that contains real value with double precision - virtual std::shared_ptr real(const std::string theID) = 0; - - /// Initializes object by the attributes: must be called just after the object is created - /// for each attribute of the object - /// \param theID identifier of the attribute that can be referenced by this ID later - /// \param theAttrType type of the created attribute (received from the type method) - virtual void addAttribute(std::string theID, std::string theAttrType) = 0; - - /// Returns the document of this data - virtual std::shared_ptr document() = 0; - -protected: - /// Objects are created for features automatically - ModelAPI_Object() - {} -}; - -#endif diff --git a/src/ModelAPI/ModelAPI_Plugin.h b/src/ModelAPI/ModelAPI_Plugin.h index 0605d8b6f..fb084002c 100644 --- a/src/ModelAPI/ModelAPI_Plugin.h +++ b/src/ModelAPI/ModelAPI_Plugin.h @@ -22,6 +22,9 @@ public: /// Creates the feature object of this plugin by the feature string ID virtual std::shared_ptr createFeature(std::string theFeatureID) = 0; + /// To virtually destroy the fields of successors + virtual ~ModelAPI_Plugin() {} + protected: /// Is needed for python wrapping by swig ModelAPI_Plugin() {}; diff --git a/src/ModelAPI/ModelAPI_PluginManager.cxx b/src/ModelAPI/ModelAPI_PluginManager.cxx index 6f9834f6a..47623f091 100644 --- a/src/ModelAPI/ModelAPI_PluginManager.cxx +++ b/src/ModelAPI/ModelAPI_PluginManager.cxx @@ -7,8 +7,8 @@ #include // to avoid unresolved ModelAPI_Feature() #include -// to avoid unresolved ModelAPI_Object() -#include +// to avoid unresolved ModelAPI_Data() +#include // to avoid unresolved ModelAPI_Plugin() #include // to avoid unresolved ModelAPI_Iterator() diff --git a/src/ModelAPI/ModelAPI_PluginManager.h b/src/ModelAPI/ModelAPI_PluginManager.h index 3250bea97..8aab3f6f4 100644 --- a/src/ModelAPI/ModelAPI_PluginManager.h +++ b/src/ModelAPI/ModelAPI_PluginManager.h @@ -46,6 +46,9 @@ public: /// Is needed for python wrapping by swig, call Get to get an instance ModelAPI_PluginManager(); + /// To virtually destroy the fields of successors + virtual ~ModelAPI_PluginManager() {} + protected: /// Creates the feature object using plugins functionality virtual std::shared_ptr createFeature(std::string theFeatureID) = 0; diff --git a/src/ModuleBase/ModuleBase_Operation.cpp b/src/ModuleBase/ModuleBase_Operation.cpp index c3a0bd6fe..9def6b185 100644 --- a/src/ModuleBase/ModuleBase_Operation.cpp +++ b/src/ModuleBase/ModuleBase_Operation.cpp @@ -10,7 +10,7 @@ #include #include #include -#include +#include #include #include @@ -263,7 +263,7 @@ void ModuleBase_Operation::storeReal(double theValue) return; } QString anId = sender()->objectName(); - std::shared_ptr aData = myFeature->data(); + std::shared_ptr aData = myFeature->data(); std::shared_ptr aReal = aData->real(anId.toStdString()); aReal->setValue(theValue); } diff --git a/src/PartSetPlugin/PartSetPlugin_Part.cxx b/src/PartSetPlugin/PartSetPlugin_Part.cxx index 5dca088f8..440eb6f25 100644 --- a/src/PartSetPlugin/PartSetPlugin_Part.cxx +++ b/src/PartSetPlugin/PartSetPlugin_Part.cxx @@ -5,7 +5,7 @@ #include "PartSetPlugin_Part.h" #include "ModelAPI_PluginManager.h" #include "ModelAPI_Document.h" -#include "ModelAPI_Object.h" +#include "ModelAPI_Data.h" #include "ModelAPI_Iterator.h" #include "ModelAPI_AttributeDocRef.h" diff --git a/src/PartSetPlugin/PartSetPlugin_Point.cxx b/src/PartSetPlugin/PartSetPlugin_Point.cxx index be95256c0..e9b0d2fe2 100644 --- a/src/PartSetPlugin/PartSetPlugin_Point.cxx +++ b/src/PartSetPlugin/PartSetPlugin_Point.cxx @@ -5,7 +5,7 @@ #include "PartSetPlugin_Point.h" #include "ModelAPI_PluginManager.h" #include "ModelAPI_Document.h" -#include "ModelAPI_Object.h" +#include "ModelAPI_Data.h" #include "ModelAPI_AttributeDouble.h" using namespace std; diff --git a/src/XGUI/XGUI_DocumentDataModel.cpp b/src/XGUI/XGUI_DocumentDataModel.cpp index c3f8a437b..b7f65b746 100644 --- a/src/XGUI/XGUI_DocumentDataModel.cpp +++ b/src/XGUI/XGUI_DocumentDataModel.cpp @@ -5,7 +5,7 @@ #include #include #include -#include +#include #include #include @@ -22,6 +22,7 @@ XGUI_DocumentDataModel::XGUI_DocumentDataModel(QObject* theParent) myDocument = aMgr->currentDocument(); // Register in event loop + Event_Loop::loop()->registerListener(this, Event_Loop::eventByName(EVENT_FEATURE_CREATED)); Event_Loop::loop()->registerListener(this, Event_Loop::eventByName(EVENT_FEATURE_UPDATED)); // Create a top part of data tree model diff --git a/src/XGUI/XGUI_PartDataModel.cpp b/src/XGUI/XGUI_PartDataModel.cpp index 4f8423f46..f68b5fc4a 100644 --- a/src/XGUI/XGUI_PartDataModel.cpp +++ b/src/XGUI/XGUI_PartDataModel.cpp @@ -4,7 +4,7 @@ #include #include #include -#include +#include #include #include diff --git a/src/XGUI/XGUI_SelectionMgr.cpp b/src/XGUI/XGUI_SelectionMgr.cpp index c4c09491d..cbff63773 100644 --- a/src/XGUI/XGUI_SelectionMgr.cpp +++ b/src/XGUI/XGUI_SelectionMgr.cpp @@ -6,7 +6,7 @@ #include #include #include -#include +#include diff --git a/src/XGUI/XGUI_Workshop.cpp b/src/XGUI/XGUI_Workshop.cpp index 682a4eea7..0aa5bde71 100644 --- a/src/XGUI/XGUI_Workshop.cpp +++ b/src/XGUI/XGUI_Workshop.cpp @@ -13,7 +13,7 @@ #include #include -#include +#include #include #include