Geant4 10.7.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
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//
27// Visualisation attribute filter utility functions.
28//
29// Jane Tinslay, September 2006
30//
31#include "G4AttFilterUtils.hh"
32#include "G4AttDef.hh"
33#include "G4AttUtils.hh"
34#include "G4AttValueFilterT.hh"
35#include "G4CreatorFactoryT.hh"
38#include "G4String.hh"
39#include "G4ThreeVector.hh"
40#include "G4TypeKey.hh"
41#include "G4TypeKeyT.hh"
42#include <assert.h>
43
44namespace G4AttFilterUtils {
45
46 namespace {
47 template <typename T>
48 G4VAttValueFilter* newFilter() {
49 return new G4AttValueFilterT<T>;
50 }
51 }
52
53 // Create new G4AttValue filter factory
56 static G4bool init(false);
57
58 if (!init) {
59 // Register typekey<->creator pairs
60 factory->Register(G4TypeKeyT<G4String>(), newFilter<G4String>);
61 factory->Register(G4TypeKeyT<G4int>(), newFilter<G4int>);
62 factory->Register(G4TypeKeyT<G4double>(), newFilter<G4double>);
63 factory->Register(G4TypeKeyT<G4ThreeVector>(), newFilter<G4ThreeVector>);
64 factory->Register(G4TypeKeyT<G4bool>(), newFilter<G4bool>);
65 factory->Register(G4TypeKeyT<G4DimensionedDouble>(), newFilter<G4DimensionedDouble>);
66 factory->Register(G4TypeKeyT<G4DimensionedThreeVector>(), newFilter<G4DimensionedThreeVector>);
67 init = true;
68 }
69
70 return factory;
71 }
72
74
75 G4TypeKey myKey = def.GetTypeKey();
76
77 // Get correct type key if original G4AttDef's being used
78 if (!myKey.IsValid()) {
79 myKey = G4AttUtils::GetKey(def);
80 }
81
82 // Should be valid now
83 assert(myKey.IsValid());
84
86
87 G4VAttValueFilter* filter = factory->Create(myKey);
88 assert (0 != filter);
89
90 return filter;
91 }
92
93}
bool G4bool
Definition: G4Types.hh:86
const G4TypeKey & GetTypeKey() const
Definition: G4AttDef.hh:88
G4bool Register(const Identifier &id, Creator creator)
T * Create(const Identifier &id) const
G4bool IsValid()
Definition: G4TypeKey.hh:49
G4CreatorFactoryT< G4VAttValueFilter, G4TypeKey, G4VAttValueFilter *(*)()> G4AttValueFilterFactory
G4AttValueFilterFactory * GetAttValueFilterFactory()
G4VAttValueFilter * GetNewFilter(const G4AttDef &def)
G4TypeKey GetKey(const G4AttDef &def)
Definition: G4AttUtils.cc:40