CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
FWViewManagerBase.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: Core
4 // Class : FWViewManagerBase
5 //
6 // Implementation:
7 // <Notes on implementation>
8 //
9 // Original Author:
10 // Created: Sat Jan 5 10:56:17 EST 2008
11 //
12 
13 // system include files
14 #include "TClass.h"
15 #include "TROOT.h"
16 #include <cassert>
17 #include <iostream>
18 #include <functional>
19 
20 // user include files
24 
25 //
26 // constants, enums and typedefs
27 //
28 
29 //
30 // static data member definitions
31 //
32 
33 //
34 // constructors and destructor
35 //
36 FWViewManagerBase::FWViewManagerBase() : m_context(nullptr), m_changeManager(nullptr), m_colorManager(nullptr) {}
37 
38 // FWViewManagerBase::FWViewManagerBase(const FWViewManagerBase& rhs)
39 // {
40 // // do actual copying here;
41 // }
42 
44 
45 //
46 // assignment operators
47 //
48 // const FWViewManagerBase& FWViewManagerBase::operator=(const FWViewManagerBase& rhs)
49 // {
50 // //An exception safe implementation is
51 // FWViewManagerBase temp(rhs);
52 // swap(rhs);
53 //
54 // return *this;
55 // }
56 
57 //
58 // member functions
59 //
60 void* FWViewManagerBase::createInstanceOf(const TClass* iBaseClass, const char* iNameOfClass) {
61  //create proxy builders
62  Int_t error;
63  assert(iBaseClass != nullptr);
64 
65  //does the class already exist?
66  TClass* c = TClass::GetClass(iNameOfClass);
67  if (nullptr == c) {
68  //try to load a macro of that name
69 
70  //How can I tell if this succeeds or failes? error and value are always 0!
71  // I could not make the non-compiled mechanism to work without seg-faults
72  // Int_t value =
73  gROOT->LoadMacro((std::string(iNameOfClass) + ".C+").c_str(), &error);
74  c = TClass::GetClass(iNameOfClass);
75  if (nullptr == c) {
76  std::cerr << "failed to find " << iNameOfClass << std::endl;
77  return nullptr;
78  }
79  }
80  void* inst = c->New();
81  void* baseClassInst = c->DynamicCast(iBaseClass, inst);
82  if (nullptr == baseClassInst) {
83  std::cerr << "conversion to " << iBaseClass->ClassName() << " for class " << iNameOfClass << " failed" << std::endl;
84  return nullptr;
85  }
86  return baseClassInst;
87 }
88 
90  //forward call to the virtual function
91  this->modelChangesComing();
92 }
94  //forward call to the virtual function
95  this->modelChangesDone();
96 }
98 
100  assert(nullptr != iCM);
101  m_changeManager = iCM;
104 }
105 
107  assert(nullptr != iCM);
108  m_colorManager = iCM;
110  //make sure to pickup any changes that occurred earlier
111  colorsChanged();
112 }
113 
114 //
115 // const member functions
116 //
117 
119  assert(m_changeManager != nullptr);
120  return *m_changeManager;
121 }
122 
124  assert(m_colorManager != nullptr);
125  return *m_colorManager;
126 }
void * createInstanceOf(const TClass *iBaseClass, const char *iNameOfClass)
const edm::EventSetup & c
virtual void modelChangesComing()=0
virtual void colorsChanged()=0
virtual void modelChangesDone()=0
FWColorManager & colorManager() const
assert(be >=bs)
sigc::signal< void()> changeSignalsAreDone_
FWModelChangeManager * m_changeManager
FWColorManager * m_colorManager
void setChangeManager(FWModelChangeManager *iCM)
FWModelChangeManager & changeManager() const
void setColorManager(FWColorManager *iCM)
sigc::signal< void()> changeSignalsAreComing_
virtual ~FWViewManagerBase()
sigc::signal< void()> colorsHaveChanged_