1 // Copyright (C) 2007-2019 CEA/DEN, EDF R&D, OPEN CASCADE
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, or (at your option) any later version.
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.
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
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #include "QtHelper.hxx"
23 // =================================================================
24 // Helper functions for DataObject and DataModel classes
25 // =================================================================
29 // A DataObject can't be used as is but must be specialized to
30 // specify the behavior in the hierarchic model.
31 #include "MyDataModel.hxx"
33 void TEST_DataObject() {
34 // In this test, the object id should increase at each instance
35 DataObject * dataObject;
36 for (int i=0; i<100; i++) {
37 dataObject = new MyDataObject();
38 QLOG("object nameId = " << dataObject->getNameId().c_str());
40 QLOG("path = " << dataObject->getPath().c_str());
41 QLOG("pathname = " << dataObject->getPathName().c_str());
43 QLOG("serialize= " << dataObject->toString().c_str());
47 void TEST_DataModel() {
48 MyDataModel * dataModel = new MyDataModel();
53 DataObject * dataObject;
54 for (int i=0; i<100; i++) {
55 // We can either create the data object using its constructor or
56 // using the factory of the model (the prefered way):
57 // dataObject = new MyDataObject();
58 dataObject = dataModel->newDataObject();
59 dataObject->setLabel("myobject"+ToString(i));
61 refNameId = dataObject->getNameId();
63 dataModel->addDataObject(dataObject);
66 dataObject = dataModel->getDataObject(refNameId);
67 QLOG("object nameId = " << dataObject->getNameId().c_str());
68 QLOG("path = " << dataObject->getPath().c_str());
69 QLOG("pathname = " << dataObject->getPathName().c_str());
73 // =================================================================
75 int main(int argc, char * argv[ ])