Back to index

salome-gui  6.5.0
DataProcessor.cxx
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // This library is free software; you can redistribute it and/or
00004 // modify it under the terms of the GNU Lesser General Public
00005 // License as published by the Free Software Foundation; either
00006 // version 2.1 of the License.
00007 //
00008 // This library is distributed in the hope that it will be useful,
00009 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00010 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011 // Lesser General Public License for more details.
00012 //
00013 // You should have received a copy of the GNU Lesser General Public
00014 // License along with this library; if not, write to the Free Software
00015 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00016 //
00017 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00018 //
00019 
00020 // Author: Guillaume Boulant (EDF/R&D)
00021 
00022 
00023 #include "DataProcessor.hxx"
00024 #include <Basics_Utils.hxx>
00025 #include "QtHelper.hxx"
00026 
00027 DataProcessor::DataProcessor(DataModel * dataModel) {
00028   _dataModel = dataModel;
00029 }
00030 
00036 DataObjectVector * DataProcessor::extract(QStringList itemNameIdList) {
00037   if ( _dataModel == NULL ) {
00038     STDLOG("No data model associated to this processor");
00039     return NULL;
00040   }
00041 
00042   DataObjectVector * dataObjectList = new DataObjectVector();
00043 
00044   // We can request the dataModel to obtain the dataObject associated
00045   // to each of the item (iteNameId is a TreeView id, Qt stuff only).
00046   QStringList::const_iterator it;
00047   for (it = itemNameIdList.constBegin(); it != itemNameIdList.constEnd(); ++it) {
00048     QString itemNameId = *it;
00049     DataObject * dataObject = _dataModel->getDataObject(QS2S(itemNameId));
00050     
00051     if ( dataObject != NULL ) {
00052       dataObjectList->push_back(dataObject);
00053     } else {
00054       LOG("No data object associated to the item "<<itemNameId);
00055     } 
00056   }
00057   return dataObjectList;
00058 }
00059 
00060 
00061 void DataProcessor::process(QStringList itemNameIdList) {
00062   if ( _dataModel == NULL ) {
00063     STDLOG("No data model");
00064     return;
00065   }
00066 
00067   this->preprocess(itemNameIdList);
00068 
00069   // We can request the dataModel to obtain the dataObject associated
00070   // to each of the item (iteNameId is a TreeView id, Qt stuff only).
00071   QStringList::const_iterator it;
00072   for (it = itemNameIdList.constBegin(); it != itemNameIdList.constEnd(); ++it) {
00073     QString itemNameId = *it;
00074     DataObject * dataObject = _dataModel->getDataObject(QS2S(itemNameId));
00075     
00076     if ( dataObject != NULL ) {
00077       this->processDataObject(dataObject);
00078     } else {
00079       STDLOG("No data object associated to the item "<<QS2S(itemNameId));
00080     } 
00081   }
00082 
00083   this->postprocess(itemNameIdList);
00084 }
00085 
00086