ROOT  6.06/09
Reference Guide
DataSetManager.cxx
Go to the documentation of this file.
1 // @(#)root/tmva $Id$
2 // Author: Andreas Hoecker, Peter Speckmayer, Joerg Stelzer, Helge Voss
3 
4 /**********************************************************************************
5  * Project: TMVA - a Root-integrated toolkit for multivariate data analysis *
6  * Package: TMVA *
7  * Class : DataSetManager *
8  * Web : http://tmva.sourceforge.net *
9  * *
10  * Description: *
11  * Implementation (see header for description) *
12  * *
13  * Authors (alphabetical): *
14  * Andreas Hoecker <Andreas.Hocker@cern.ch> - CERN, Switzerland *
15  * Joerg Stelzer <Joerg.Stelzer@cern.ch> - CERN, Switzerland *
16  * Helge Voss <Helge.Voss@cern.ch> - MPI-K Heidelberg, Germany *
17  * *
18  * Copyright (c) 2006: *
19  * CERN, Switzerland *
20  * MPI-K Heidelberg, Germany *
21  * *
22  * Redistribution and use in source and binary forms, with or without *
23  * modification, are permitted according to the terms listed in LICENSE *
24  * (http://tmva.sourceforge.net/LICENSE) *
25  **********************************************************************************/
26 
27 #include <vector>
28 #include <iostream>
29 using std::endl;
30 
31 #ifndef ROOT_TMVA_DataSetManager
32 #include "TMVA/DataSetManager.h"
33 #endif
34 #ifndef ROOT_TMVA_DataSetFactory
35 #include "TMVA/DataSetFactory.h"
36 #endif
37 #ifndef ROOT_TMVA_DataSet
38 #include "TMVA/DataSet.h"
39 #endif
40 #ifndef ROOT_TMVA_DataSetInfo
41 #include "TMVA/DataSetInfo.h"
42 #endif
43 #ifndef ROOT_TMVA_MsgLogger
44 #include "TMVA/MsgLogger.h"
45 #endif
46 
47 //TMVA::DataSetManager* TMVA::DataSetManager::fgDSManager = 0; // DSMTEST removed
48 //TMVA::DataSetManager& TMVA::DataSetManager::Instance() { return *fgDSManager; } // DSMTEST removed
49 // void TMVA::DataSetManager::CreateInstance( DataInputHandler& dataInput ) { fgDSManager = new DataSetManager(dataInput); } // DSMTEST removed
50 
51 // void TMVA::DataSetManager::DestroyInstance() { if (fgDSManager) { delete fgDSManager; fgDSManager=0; } } // DSMTEST removed
52 
53 ////////////////////////////////////////////////////////////////////////////////
54 /// constructor
55 
57  : fDatasetFactory(0),
58  fDataInput(dataInput),
59  fDataSetInfoCollection(),
60  fLogger( new MsgLogger("DataSetManager", kINFO) )
61 {
62 }
63 
64 ////////////////////////////////////////////////////////////////////////////////
65 /// destructor
66 /// fDataSetInfoCollection.SetOwner(); // DSMTEST --> created a segfault because the DataSetInfo-objects got deleted twice
67 
69 {
70  DataSetFactory::destroyNewInstance(fDatasetFactory);
71 
72  delete fLogger;
73 }
74 
75 ////////////////////////////////////////////////////////////////////////////////
76 /// Creates the singleton dataset
77 
79 {
80  DataSetInfo* dsi = GetDataSetInfo( dsiName );
81  if (!dsi) Log() << kFATAL << "DataSetInfo object '" << dsiName << "' not found" << Endl;
82 
83  // factory to create dataset from datasetinfo and datainput
84  if(!fDatasetFactory) { fDatasetFactory = DataSetFactory::NewInstance(); }
85  return fDatasetFactory->CreateDataSet( *dsi, fDataInput );
86 }
87 
88 ////////////////////////////////////////////////////////////////////////////////
89 /// returns datasetinfo object for given name
90 
92 {
93  return (DataSetInfo*)fDataSetInfoCollection.FindObject( dsiName );
94 }
95 
96 ////////////////////////////////////////////////////////////////////////////////
97 /// stores a copy of the dataset info object
98 
100 {
101  dsi.SetDataSetManager( this ); // DSMTEST
102 
103  DataSetInfo * dsiInList = GetDataSetInfo(dsi.GetName());
104  if (dsiInList!=0) return *dsiInList;
105  fDataSetInfoCollection.Add( const_cast<DataSetInfo*>(&dsi) );
106  return dsi;
107 }
DataSetInfo * GetDataSetInfo(const TString &dsiName)
returns datasetinfo object for given name
MsgLogger & Endl(MsgLogger &ml)
Definition: MsgLogger.h:162
DataSet * CreateDataSet(const TString &dsiName)
Creates the singleton dataset.
Basic string class.
Definition: TString.h:137
void SetDataSetManager(DataSetManager *dsm)
Definition: DataSetInfo.h:194
virtual const char * GetName() const
Returns name of object.
Definition: DataSetInfo.h:85
DataSetInfo & AddDataSetInfo(DataSetInfo &dsi)
stores a copy of the dataset info object
static DataSetFactory * NewInstance()
virtual TObject * FindObject(const char *name) const
Must be redefined in derived classes.
Definition: TObject.cxx:379
~DataSetManager()
destructor fDataSetInfoCollection.SetOwner(); // DSMTEST –> created a segfault because the DataSetIn...
Definition: math.cpp:60
static void destroyNewInstance(DataSetFactory *iOther)