Geant4
9.6.p02
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
geant4_9_6_p02
source
visualization
modeling
src
G4AttFilterUtils.cc
Go to the documentation of this file.
1
//
2
// ********************************************************************
3
// * License and Disclaimer *
4
// * *
5
// * The Geant4 software is copyright of the Copyright Holders of *
6
// * the Geant4 Collaboration. It is provided under the terms and *
7
// * conditions of the Geant4 Software License, included in the file *
8
// * LICENSE and available at http://cern.ch/geant4/license . These *
9
// * include a list of copyright holders. *
10
// * *
11
// * Neither the authors of this software system, nor their employing *
12
// * institutes,nor the agencies providing financial support for this *
13
// * work make any representation or warranty, express or implied, *
14
// * regarding this software system or assume any liability for its *
15
// * use. Please see the license in the file LICENSE and URL above *
16
// * for the full disclaimer and the limitation of liability. *
17
// * *
18
// * This code implementation is the result of the scientific and *
19
// * technical work of the GEANT4 collaboration. *
20
// * By using, copying, modifying or distributing the software (or *
21
// * any work based on the software) you agree to acknowledge its *
22
// * use in resulting scientific publications, and indicate your *
23
// * acceptance of all terms of the Geant4 Software license. *
24
// ********************************************************************
25
//
26
// $Id$
27
//
28
// Visualisation attribute filter utility functions.
29
//
30
// Jane Tinslay, September 2006
31
//
32
#include "
G4AttFilterUtils.hh
"
33
#include "
G4AttDef.hh
"
34
#include "
G4AttUtils.hh
"
35
#include "
G4AttValueFilterT.hh
"
36
#include "
G4CreatorFactoryT.hh
"
37
#include "
G4DimensionedDouble.hh
"
38
#include "
G4DimensionedThreeVector.hh
"
39
#include "G4String.hh"
40
#include "
G4ThreeVector.hh
"
41
#include "
G4TypeKey.hh
"
42
#include "
G4TypeKeyT.hh
"
43
#include <assert.h>
44
45
namespace
G4AttFilterUtils {
46
47
namespace
{
48
template
<
typename
T>
49
G4VAttValueFilter
* newFilter() {
50
return
new
G4AttValueFilterT<T>
;
51
}
52
}
53
54
// Create new G4AttValue filter factory
55
G4AttValueFilterFactory
*
GetAttValueFilterFactory
() {
56
static
G4AttValueFilterFactory
* factory =
new
G4AttValueFilterFactory
;
57
static
G4bool
init(
false
);
58
59
if
(!init) {
60
// Register typekey<->creator pairs
61
factory->
Register
(
G4TypeKeyT<G4String>
(), newFilter<G4String>);
62
factory->
Register
(
G4TypeKeyT<G4int>
(), newFilter<G4int>);
63
factory->
Register
(
G4TypeKeyT<G4double>
(), newFilter<G4double>);
64
factory->
Register
(
G4TypeKeyT<G4ThreeVector>
(), newFilter<G4ThreeVector>);
65
factory->
Register
(
G4TypeKeyT<G4bool>
(), newFilter<G4bool>);
66
factory->
Register
(
G4TypeKeyT<G4DimensionedDouble>
(), newFilter<G4DimensionedDouble>);
67
factory->
Register
(
G4TypeKeyT<G4DimensionedThreeVector>
(), newFilter<G4DimensionedThreeVector>);
68
init =
true
;
69
}
70
71
return
factory;
72
}
73
74
G4VAttValueFilter
*
GetNewFilter
(
const
G4AttDef
& def) {
75
76
G4TypeKey
myKey = def.
GetTypeKey
();
77
78
// Get correct type key if original G4AttDef's being used
79
if
(!myKey.
IsValid
()) {
80
myKey =
G4AttUtils::GetKey
(def);
81
}
82
83
// Should be valid now
84
assert(myKey.
IsValid
());
85
86
G4AttValueFilterFactory
* factory =
GetAttValueFilterFactory
();
87
88
G4VAttValueFilter
* filter = factory->Create(myKey);
89
assert (0 != filter);
90
91
return
filter;
92
}
93
94
}
Generated on Sat May 25 2013 14:34:16 for Geant4 by
1.8.4