TpcContFact.cxx 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /////////////////////////////////////////////////////////////
  2. //
  3. // TpcContFact
  4. //
  5. // Factory for the parameter containers in libTst
  6. //
  7. /////////////////////////////////////////////////////////////
  8. using namespace std;
  9. #include "TpcContFact.h"
  10. #include "FairRuntimeDb.h"
  11. #include "TpcGeoPar.h"
  12. #include "FairParRootFileIo.h"
  13. #include "FairParAsciiFileIo.h"
  14. //#include "FairParIo.h"
  15. //#include "TpcParRootFileIo.h"
  16. //#include "TpcParAsciiFileIo.h"
  17. #include <iostream>
  18. #include <iomanip>
  19. ClassImp(TpcContFact)
  20. static TpcContFact gTpcContFact;
  21. TpcContFact::TpcContFact() {
  22. // Constructor (called when the library is loaded)
  23. fName="TpcContFact";
  24. fTitle="Factory for parameter containers in libTpc";
  25. setAllContainers();
  26. FairRuntimeDb::instance()->addContFactory(this);
  27. }
  28. void TpcContFact::setAllContainers() {
  29. /** Creates the Container objects with all accepted contexts and adds them to
  30. * the list of containers for the TST library.*/
  31. FairContainer* p= new FairContainer("TpcGeoPar",
  32. "Tpc Geometry Parameters",
  33. "TpcDefaultContext");
  34. p->addContext("TpcNonDefaultContext");
  35. containers->Add(p);
  36. }
  37. FairParSet* TpcContFact::createContainer(FairContainer* c) {
  38. /** Calls the constructor of the corresponding parameter container.
  39. * For an actual context, which is not an empty string and not the default context
  40. * of this container, the name is concatinated with the context. */
  41. const char* name=c->GetName();
  42. FairParSet* p=NULL;
  43. if (strcmp(name,"TpcGeoPar")==0) {
  44. p=new TpcGeoPar(c->getConcatName().Data(),c->GetTitle(),c->getContext());
  45. }
  46. return p;
  47. }
  48. /*void TpcContFact::activateParIo(FairParIo* io) {
  49. // activates the input/output class for the parameters
  50. // needed by the Tst
  51. if (strcmp(io->IsA()->GetName(),"FairParRootFileIo")==0) {
  52. TpcParRootFileIo* p=new TpcParRootFileIo(((FairParRootFileIo*)io)->getParRootFile());
  53. io->setDetParIo(p);
  54. }
  55. if (strcmp(io->IsA()->GetName(),"FairParAsciiFileIo")==0) {
  56. TpcParAsciiFileIo* p=new TpcParAsciiFileIo(((FairParAsciiFileIo*)io)->getFile());
  57. io->setDetParIo(p);
  58. }
  59. }*/