CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros 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 <assert.h>
17 #include <iostream>
18 #include <boost/bind.hpp>
19 
20 // user include files
24 
25 
26 //
27 // constants, enums and typedefs
28 //
29 
30 //
31 // static data member definitions
32 //
33 
34 //
35 // constructors and destructor
36 //
38  m_context(0),
39  m_changeManager(0),
40  m_colorManager(0)
41 {
42 }
43 
44 // FWViewManagerBase::FWViewManagerBase(const FWViewManagerBase& rhs)
45 // {
46 // // do actual copying here;
47 // }
48 
50 {
51 }
52 
53 //
54 // assignment operators
55 //
56 // const FWViewManagerBase& FWViewManagerBase::operator=(const FWViewManagerBase& rhs)
57 // {
58 // //An exception safe implementation is
59 // FWViewManagerBase temp(rhs);
60 // swap(rhs);
61 //
62 // return *this;
63 // }
64 
65 //
66 // member functions
67 //
68 void*
69 FWViewManagerBase::createInstanceOf(const TClass* iBaseClass,
70  const char* iNameOfClass)
71 {
72  //create proxy builders
73  Int_t error;
74  assert(iBaseClass !=0);
75 
76  //does the class already exist?
77  TClass *c = TClass::GetClass( iNameOfClass );
78  if(0==c) {
79  //try to load a macro of that name
80 
81  //How can I tell if this succeeds or failes? error and value are always 0!
82  // I could not make the non-compiled mechanism to work without seg-faults
83  // Int_t value =
84  gROOT->LoadMacro( (std::string(iNameOfClass)+".C+").c_str(), &error );
85  c = TClass::GetClass( iNameOfClass );
86  if(0==c ) {
87  std::cerr <<"failed to find "<< iNameOfClass << std::endl;
88  return 0;
89  }
90  }
91  void* inst = c->New();
92  void* baseClassInst = c->DynamicCast(iBaseClass,inst);
93  if(0==baseClassInst) {
94  std::cerr<<"conversion to "<<iBaseClass->ClassName() << " for class " << iNameOfClass << " failed"<<std::endl;
95  return 0;
96  }
97  return baseClassInst;
98 }
99 
100 void
102 {
103  //forward call to the virtual function
104  this->modelChangesComing();
105 }
106 void
108 {
109  //forward call to the virtual function
110  this->modelChangesDone();
111 }
112 void
114 {
115  this->colorsChanged();
116 }
117 
118 
119 void
121 {
122  assert(0!=iCM);
123  m_changeManager = iCM;
126 }
127 
128 void
130 {
131  assert(0!= iCM);
132  m_colorManager = iCM;
134  //make sure to pickup any changes that occurred earlier
135  colorsChanged();
136 }
137 
138 //
139 // const member functions
140 //
141 
144 {
145  assert(m_changeManager != 0);
146  return *m_changeManager;
147 }
148 
151 {
152  assert(m_colorManager !=0);
153  return *m_colorManager;
154 }
155 
void * createInstanceOf(const TClass *iBaseClass, const char *iNameOfClass)
virtual void modelChangesComing()=0
virtual void colorsChanged()=0
assert(m_qm.get())
virtual void modelChangesDone()=0
FWColorManager & colorManager() const
FWModelChangeManager * m_changeManager
FWColorManager * m_colorManager
sigc::signal< void > changeSignalsAreDone_
void setChangeManager(FWModelChangeManager *iCM)
FWModelChangeManager & changeManager() const
sigc::signal< void > changeSignalsAreComing_
void setColorManager(FWColorManager *iCM)
sigc::signal< void > colorsHaveChanged_
virtual ~FWViewManagerBase()