BOSS 6.6.4.p03
BESIII Offline Software System
Loading...
Searching...
No Matches
EvtModel.cc
Go to the documentation of this file.
1//--------------------------------------------------------------------------
2//
3// Environment:
4// This software is part of the EvtGen package developed jointly
5// for the BaBar and CLEO collaborations. If you use all or part
6// of it, please give an appropriate acknowledgement.
7//
8// Copyright Information: See EvtGen/COPYRIGHT
9// Copyright (C) 1998 Caltech, UCSB
10//
11// Module: EvtModel.cc
12//
13// Description:
14//
15// Modification history:
16//
17// RYD September 25, 1996 Module created
18//
19//------------------------------------------------------------------------
20//
22#include <iostream>
23#include <iomanip>
24#include <fstream>
25#include <ctype.h>
26#include <stdlib.h>
27#include <assert.h>
31#include "EvtGenBase/EvtPDL.hh"
37#include <string>
38using std::fstream;
39
40EvtModel* EvtModel::_instance=0;
41
42EvtModel::EvtModel() {
43
44}
45
46EvtDecayBase* EvtModel::getFcn(std::string model_name){
47
48 EvtDecayBase *model=0;
49 if ( _modelNameHash.find(model_name)!=_modelNameHash.end() ) {
50 model=_modelNameHash[model_name];
51 }
52
53 if (model==0){
54 report(ERROR,"EvtGen") << "Did not find the right model:"
55 <<model_name.c_str()<<"\n";
56 return 0;
57 }
58
59 return model->clone();
60
61}
62
63
65
66 std::string modelName;
67 prototype->getName(modelName);
68
69 _modelNameHash[modelName]=prototype;
70
71 std::string commandName=prototype->commandName();
72
73 if (commandName!=""){
74
75 //report(DEBUG,"EvtGen") << "Adding command:"<<commandName<<endl;
76
77 _commandNameHash[commandName]=prototype;
78
79 }
80
81}
82
83int EvtModel::isModel(std::string model_name){
84
85 if ( _modelNameHash.find(model_name)!=_modelNameHash.end() ) {
86 return 1;
87 }
88 return 0;
89}
90
91
92int EvtModel::isCommand(std::string cmd){
93
94 if ( _commandNameHash.find(cmd)!=_commandNameHash.end() ) {
95 return 1;
96 }
97 return 0;
98}
99
100void EvtModel::storeCommand(std::string cmd,std::string cnfgstr){
101
102 EvtDecayBase *model=0;
103 if ( _commandNameHash.find(cmd)!=_commandNameHash.end() ) {
104 model=_commandNameHash[cmd];
105 }
106
107 assert(model!=0);
108
109 model->command(cnfgstr);
110
111}
112
113
114
115
ostream & report(Severity severity, const char *facility)
Definition: EvtReport.cc:36
@ ERROR
Definition: EvtReport.hh:49
virtual EvtDecayBase * clone()=0
virtual void getName(std::string &name)=0
virtual void command(std::string cmd)
virtual std::string commandName()
EvtDecayBase * getFcn(std::string model_name)
Definition: EvtModel.cc:46
void storeCommand(std::string cmd, std::string cnfgstr)
Definition: EvtModel.cc:100
void Register(EvtDecayBase *prototype)
Definition: EvtModel.cc:64
int isModel(std::string name)
Definition: EvtModel.cc:83
int isCommand(std::string cmd)
Definition: EvtModel.cc:92