Salome HOME
Copyrights update
[modules/gui.git] / src / CAM / CAM_DataModel.h
1 // Copyright (C) 2005  OPEN CASCADE, CEA/DEN, EDF R&D, PRINCIPIA R&D
2 // 
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either 
6 // version 2.1 of the License.
7 // 
8 // This library is distributed in the hope that it will be useful 
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of 
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public  
14 // License along with this library; if not, write to the Free Software 
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/
18 //
19 #ifndef CAM_DATAMODEL_H
20 #define CAM_DATAMODEL_H
21
22 #include "CAM.h"
23
24 #include <qobject.h>
25 #include <qstringlist.h>
26
27 class CAM_Module;
28 class CAM_DataObject;
29 class CAM_Study;
30 class SUIT_DataObject;
31
32 class CAM_EXPORT CAM_DataModel : public QObject
33 {
34   Q_OBJECT
35
36 public:
37   CAM_DataModel( CAM_Module* );
38   virtual ~CAM_DataModel();
39
40   virtual void     initialize();
41
42   CAM_DataObject*  root() const;
43   CAM_Module*      module() const;
44
45   /** @name These methods should be redefined in successors.*/
46   //@{
47   virtual bool     open( const QString&, CAM_Study*, QStringList ) { return true; }//!< return true
48   virtual bool     save( QStringList& ) { return true; };
49   virtual bool     saveAs( const QString&, CAM_Study*, QStringList&  ) { return true; };
50   virtual bool     close() { return true; };
51   virtual bool     create( CAM_Study* ) { return true; }
52   //@}
53
54 protected:
55   /*! setRoot() should be used to specify custom root object instance.\n
56    * Such an object can be created in several ways, depending on application or module needs:\n
57    * \li by initialize()
58    * \li while the model is being loaded
59    * \li when the model is updated and becomes non-empty 
60    */
61   virtual void     setRoot( const CAM_DataObject* );
62
63 private slots:
64   void             onDestroyed( SUIT_DataObject* );
65
66 signals:
67   void             rootChanged( const CAM_DataModel* );
68
69 private:
70   CAM_DataObject*  myRoot;
71   CAM_Module*      myModule;
72 };
73
74 #endif