ROOT  6.07/01
Reference Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 #include "TMVA/Types.h"
48 
49 //TMVA::DataSetManager* TMVA::DataSetManager::fgDSManager = 0; // DSMTEST removed
50 //TMVA::DataSetManager& TMVA::DataSetManager::Instance() { return *fgDSManager; } // DSMTEST removed
51 // void TMVA::DataSetManager::CreateInstance( DataInputHandler& dataInput ) { fgDSManager = new DataSetManager(dataInput); } // DSMTEST removed
52 
53 // void TMVA::DataSetManager::DestroyInstance() { if (fgDSManager) { delete fgDSManager; fgDSManager=0; } } // DSMTEST removed
54 
55 ////////////////////////////////////////////////////////////////////////////////
56 /// constructor
57 
59  : fDatasetFactory(0),
60  fDataInput(dataInput),
61  fDataSetInfoCollection(),
62  fLogger( new MsgLogger("DataSetManager", kINFO) )
63 {
64 }
65 
66 ////////////////////////////////////////////////////////////////////////////////
67 /// destructor
68 /// fDataSetInfoCollection.SetOwner(); // DSMTEST --> created a segfault because the DataSetInfo-objects got deleted twice
69 
71 {
72  DataSetFactory::destroyNewInstance(fDatasetFactory);
73 
74  delete fLogger;
75 }
76 
77 ////////////////////////////////////////////////////////////////////////////////
78 /// Creates the singleton dataset
79 
81 {
82  DataSetInfo* dsi = GetDataSetInfo( dsiName );
83  if (!dsi) Log() << kFATAL << "DataSetInfo object '" << dsiName << "' not found" << Endl;
84 
85  // factory to create dataset from datasetinfo and datainput
86  if(!fDatasetFactory) { fDatasetFactory = DataSetFactory::NewInstance(); }
87  return fDatasetFactory->CreateDataSet( *dsi, fDataInput );
88 }
89 
90 ////////////////////////////////////////////////////////////////////////////////
91 /// returns datasetinfo object for given name
92 
94 {
95  return (DataSetInfo*)fDataSetInfoCollection.FindObject( dsiName );
96 }
97 
98 ////////////////////////////////////////////////////////////////////////////////
99 /// stores a copy of the dataset info object
100 
102 {
103  dsi.SetDataSetManager( this ); // DSMTEST
104 
105  DataSetInfo * dsiInList = GetDataSetInfo(dsi.GetName());
106  if (dsiInList!=0) return *dsiInList;
107  fDataSetInfoCollection.Add( const_cast<DataSetInfo*>(&dsi) );
108  return dsi;
109 }
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 DataSetInf...
Definition: math.cpp:60
static void destroyNewInstance(DataSetFactory *iOther)