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 // $Id: FWViewManagerBase.cc,v 1.14 2010/04/08 19:45:25 amraktad Exp $
12 //
13 
14 // system include files
15 #include "TClass.h"
16 #include "TROOT.h"
17 #include <assert.h>
18 #include <iostream>
19 #include <boost/bind.hpp>
20 
21 // user include files
25 
26 
27 //
28 // constants, enums and typedefs
29 //
30 
31 //
32 // static data member definitions
33 //
34 
35 //
36 // constructors and destructor
37 //
39  m_context(0),
40  m_changeManager(0),
41  m_colorManager(0)
42 {
43 }
44 
45 // FWViewManagerBase::FWViewManagerBase(const FWViewManagerBase& rhs)
46 // {
47 // // do actual copying here;
48 // }
49 
51 {
52 }
53 
54 //
55 // assignment operators
56 //
57 // const FWViewManagerBase& FWViewManagerBase::operator=(const FWViewManagerBase& rhs)
58 // {
59 // //An exception safe implementation is
60 // FWViewManagerBase temp(rhs);
61 // swap(rhs);
62 //
63 // return *this;
64 // }
65 
66 //
67 // member functions
68 //
69 void*
70 FWViewManagerBase::createInstanceOf(const TClass* iBaseClass,
71  const char* iNameOfClass)
72 {
73  //create proxy builders
74  Int_t error;
75  assert(iBaseClass !=0);
76 
77  //does the class already exist?
78  TClass *c = TClass::GetClass( iNameOfClass );
79  if(0==c) {
80  //try to load a macro of that name
81 
82  //How can I tell if this succeeds or failes? error and value are always 0!
83  // I could not make the non-compiled mechanism to work without seg-faults
84  // Int_t value =
85  gROOT->LoadMacro( (std::string(iNameOfClass)+".C+").c_str(), &error );
86  c = TClass::GetClass( iNameOfClass );
87  if(0==c ) {
88  std::cerr <<"failed to find "<< iNameOfClass << std::endl;
89  return 0;
90  }
91  }
92  void* inst = c->New();
93  void* baseClassInst = c->DynamicCast(iBaseClass,inst);
94  if(0==baseClassInst) {
95  std::cerr<<"conversion to "<<iBaseClass->ClassName() << " for class " << iNameOfClass << " failed"<<std::endl;
96  return 0;
97  }
98  return baseClassInst;
99 }
100 
101 void
103 {
104  //forward call to the virtual function
105  this->modelChangesComing();
106 }
107 void
109 {
110  //forward call to the virtual function
111  this->modelChangesDone();
112 }
113 void
115 {
116  this->colorsChanged();
117 }
118 
119 
120 void
122 {
123  assert(0!=iCM);
124  m_changeManager = iCM;
127 }
128 
129 void
131 {
132  assert(0!= iCM);
133  m_colorManager = iCM;
135  //make sure to pickup any changes that occurred earlier
136  colorsChanged();
137 }
138 
139 //
140 // const member functions
141 //
142 
145 {
146  assert(m_changeManager != 0);
147  return *m_changeManager;
148 }
149 
152 {
153  assert(m_colorManager !=0);
154  return *m_colorManager;
155 }
156 
157 
158 //
159 // static member functions
160 //
void * createInstanceOf(const TClass *iBaseClass, const char *iNameOfClass)
virtual void modelChangesComing()=0
virtual void colorsChanged()=0
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()