Geant4 9.6.0
Toolkit for the simulation of the passage of particles through matter
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
G4ITType.hh
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: G4ITType.hh 64057 2012-10-30 15:04:49Z gcosmo $
27//
28// Author: Mathieu Karamitros (kara (AT) cenbg . in2p3 . fr)
29//
30// WARNING : This class is released as a prototype.
31// It might strongly evolve or even disapear in the next releases.
32//
33// History:
34// -----------
35// 10 Oct 2011 M.Karamitros created
36//
37// -------------------------------------------------------------------
38
39#ifndef G4ITTYPE_HH
40#define G4ITTYPE_HH 1
41
42#include <cstddef>
43
44/**
45 * Tag the G4IT
46 * Should be automatically setup by G4IT
47 * using : ITDef(MyIT) and ITImp(MyIT)
48 */
49
51{
52private :
53 friend G4ITType operator +(const G4ITType& left,const int& right);
54 friend G4ITType operator -(const G4ITType& left,const int& right);
55 int fValue;
56
57public :
58
59 static size_t size();
60
61 G4ITType(const int d_ = 0) : fValue(d_) {;}
62 G4ITType(const G4ITType & d_) : fValue(d_.fValue){;}
63 G4ITType & operator=(const G4ITType & rhs);
64 inline G4ITType & operator=(const int & rhs) { fValue = rhs; return *this;}
65 inline operator int & () { return fValue; }
66 inline operator const int & () const { return fValue; }
67 inline bool operator==(const G4ITType & rhs) const { return fValue == rhs.fValue; }
68 inline bool operator==(const int & rhs) const { return fValue == rhs; }
69 inline bool operator<(const G4ITType & rhs) const { return fValue < rhs.fValue; }
70 inline void operator++() { fValue++; }
71};
72
73inline G4ITType operator +(const G4ITType& left,const int& right) {
74 G4ITType output( left.fValue + right );
75 return output;
76}
77
78inline G4ITType operator -(const G4ITType& left,const int& right) {
79 G4ITType output( left.fValue - right );
80 return output;
81}
82
84{
85private:
86 static G4ITTypeManager* fgInstance ;
87 G4ITType fLastType;
89 virtual ~G4ITTypeManager();
90
91public :
93 size_t size() const;
94 static G4ITTypeManager* Instance();
95 static void DeleteInstance();
96};
97
98#define ITDef(T)\
99public:\
100static G4ITType fType;\
101static const G4ITType ITType()\
102{\
103 return fType;\
104}\
105const G4ITType GetITType() const\
106{\
107 return fType;\
108}\
109virtual G4bool equal(const G4IT &right) const \
110{\
111 const T& right_mol = (const T&)right ;\
112 return (this->operator==(right_mol));\
113}\
114virtual G4bool diff(const G4IT &right) const\
115{\
116 const T& right_mol = (const T&)right ;\
117 return (this->operator<(right_mol));\
118}
119
120#define ITImp(T) \
121G4ITType T::fType = G4ITTypeManager::Instance()->NewType();
122
123#endif // G4ITTYPE_HH
G4ITType operator+(const G4ITType &left, const int &right)
Definition: G4ITType.hh:73
G4ITType operator-(const G4ITType &left, const int &right)
Definition: G4ITType.hh:78
G4ITType NewType()
Definition: G4ITType.cc:78
static G4ITTypeManager * Instance()
Definition: G4ITType.cc:53
static void DeleteInstance()
Definition: G4ITType.cc:62
size_t size() const
Definition: G4ITType.cc:73
friend G4ITType operator+(const G4ITType &left, const int &right)
Definition: G4ITType.hh:73
G4ITType(const G4ITType &d_)
Definition: G4ITType.hh:62
G4ITType & operator=(const int &rhs)
Definition: G4ITType.hh:64
G4ITType(const int d_=0)
Definition: G4ITType.hh:61
bool operator<(const G4ITType &rhs) const
Definition: G4ITType.hh:69
G4ITType & operator=(const G4ITType &rhs)
Definition: G4ITType.cc:46
bool operator==(const G4ITType &rhs) const
Definition: G4ITType.hh:67
friend G4ITType operator-(const G4ITType &left, const int &right)
Definition: G4ITType.hh:78
bool operator==(const int &rhs) const
Definition: G4ITType.hh:68
void operator++()
Definition: G4ITType.hh:70
static size_t size()
Definition: G4ITType.cc:41