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: pyG4ProcessManager.cc,v 1.4 2006/06/29 15:34:55 gunter Exp $ |
---|
27 | // $Name: geant4-09-04-beta-01 $ |
---|
28 | // ==================================================================== |
---|
29 | // pyG4ProcessManager.cc |
---|
30 | // |
---|
31 | // 2005 Q |
---|
32 | // ==================================================================== |
---|
33 | #include <boost/python.hpp> |
---|
34 | #include "G4ProcessManager.hh" |
---|
35 | |
---|
36 | using namespace boost::python; |
---|
37 | |
---|
38 | // ==================================================================== |
---|
39 | // thin wrappers |
---|
40 | // ==================================================================== |
---|
41 | namespace pyG4ProcessManager { |
---|
42 | |
---|
43 | // GetProcessList() |
---|
44 | // raw vector pointer -> Python list conversion |
---|
45 | list f_GetProcessList(const G4ProcessManager* procMgr) |
---|
46 | { |
---|
47 | list procList; |
---|
48 | G4ProcessVector* procVec= procMgr-> GetProcessList(); |
---|
49 | G4int nproc= procVec-> size(); |
---|
50 | for(G4int i=0; i< nproc; i++) { |
---|
51 | procList.append(&(*procVec)[i]); |
---|
52 | } |
---|
53 | return procList; |
---|
54 | } |
---|
55 | |
---|
56 | // GetProcessVector() |
---|
57 | list f_GetProcessVector(const G4ProcessManager* procMgr, |
---|
58 | G4ProcessVectorDoItIndex idx, |
---|
59 | G4ProcessVectorTypeIndex typ= typeGPIL ) |
---|
60 | { |
---|
61 | list procList; |
---|
62 | G4ProcessVector* procVec= procMgr-> GetProcessVector(idx, typ); |
---|
63 | G4int nproc= procVec-> size(); |
---|
64 | for(G4int i=0; i< nproc; i++) { |
---|
65 | procList.append(&(*procVec)[i]); |
---|
66 | } |
---|
67 | return procList; |
---|
68 | } |
---|
69 | |
---|
70 | BOOST_PYTHON_FUNCTION_OVERLOADS(g_GetProcessVector, |
---|
71 | f_GetProcessVector, 2, 3); |
---|
72 | |
---|
73 | // GetAtRestProcessVector() |
---|
74 | list f_GetAtRestProcessVector(const G4ProcessManager* procMgr, |
---|
75 | G4ProcessVectorTypeIndex typ= typeGPIL ) |
---|
76 | { |
---|
77 | list procList; |
---|
78 | G4ProcessVector* procVec= procMgr-> GetAtRestProcessVector(typ); |
---|
79 | G4int nproc= procVec-> size(); |
---|
80 | for(G4int i=0; i< nproc; i++) { |
---|
81 | procList.append(&(*procVec)[i]); |
---|
82 | } |
---|
83 | return procList; |
---|
84 | } |
---|
85 | |
---|
86 | BOOST_PYTHON_FUNCTION_OVERLOADS(g_GetAtRestProcessVector, |
---|
87 | f_GetAtRestProcessVector, 1, 2); |
---|
88 | |
---|
89 | // GetAlongStepProcessVector() |
---|
90 | list f_GetAlongStepProcessVector(const G4ProcessManager* procMgr, |
---|
91 | G4ProcessVectorTypeIndex typ= typeGPIL ) |
---|
92 | { |
---|
93 | list procList; |
---|
94 | G4ProcessVector* procVec= procMgr-> GetAlongStepProcessVector(typ); |
---|
95 | G4int nproc= procVec-> size(); |
---|
96 | for(G4int i=0; i< nproc; i++) { |
---|
97 | procList.append(&(*procVec)[i]); |
---|
98 | } |
---|
99 | return procList; |
---|
100 | } |
---|
101 | |
---|
102 | BOOST_PYTHON_FUNCTION_OVERLOADS(g_GetAlongStepProcessVector, |
---|
103 | f_GetAlongStepProcessVector, 1, 2); |
---|
104 | |
---|
105 | // GetPostStepProcessVector() |
---|
106 | list f_GetPostStepProcessVector(const G4ProcessManager* procMgr, |
---|
107 | G4ProcessVectorTypeIndex typ= typeGPIL ) |
---|
108 | { |
---|
109 | list procList; |
---|
110 | G4ProcessVector* procVec= procMgr-> GetPostStepProcessVector(typ); |
---|
111 | G4int nproc= procVec-> size(); |
---|
112 | for(G4int i=0; i< nproc; i++) { |
---|
113 | procList.append(&(*procVec)[i]); |
---|
114 | } |
---|
115 | return procList; |
---|
116 | } |
---|
117 | |
---|
118 | BOOST_PYTHON_FUNCTION_OVERLOADS(g_GetPostStepProcessVector, |
---|
119 | f_GetPostStepProcessVector, 1, 2); |
---|
120 | |
---|
121 | |
---|
122 | // GetProcessVectorIndex... |
---|
123 | BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(f_GetProcessVectorIndex, |
---|
124 | GetProcessVectorIndex, 2, 3); |
---|
125 | |
---|
126 | BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(f_GetAtRestIndex, |
---|
127 | GetAtRestIndex, 1, 2); |
---|
128 | |
---|
129 | BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(f_GetAlongStepIndex, |
---|
130 | GetAlongStepIndex, 1, 2); |
---|
131 | |
---|
132 | BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(f_GetPostStepIndex, |
---|
133 | GetPostStepIndex, 1, 2); |
---|
134 | // AddProcess... |
---|
135 | BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(f_AddProcess, AddProcess, 1, 4); |
---|
136 | BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(f_AddRestProcess, |
---|
137 | AddRestProcess, 1, 2); |
---|
138 | BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(f_AddDiscreteProcess, |
---|
139 | AddDiscreteProcess, 1, 2); |
---|
140 | BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(f_AddContinuousProcess, |
---|
141 | AddContinuousProcess, 1, 2); |
---|
142 | // SetProcessOrdering |
---|
143 | BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(f_SetProcessOrdering, |
---|
144 | SetProcessOrdering, 2, 3); |
---|
145 | |
---|
146 | // RemoveProcess... |
---|
147 | G4VProcess*(G4ProcessManager::*f1_RemoveProcess)(G4VProcess*) |
---|
148 | = &G4ProcessManager::RemoveProcess; |
---|
149 | |
---|
150 | G4VProcess*(G4ProcessManager::*f2_RemoveProcess)(G4int) |
---|
151 | = &G4ProcessManager::RemoveProcess; |
---|
152 | |
---|
153 | // Set/GetProcessActivation... |
---|
154 | G4VProcess*(G4ProcessManager::*f1_SetProcessActivation)(G4VProcess*, G4bool) |
---|
155 | = &G4ProcessManager::SetProcessActivation; |
---|
156 | |
---|
157 | G4VProcess*(G4ProcessManager::*f2_SetProcessActivation)(G4int, G4bool) |
---|
158 | = &G4ProcessManager::SetProcessActivation; |
---|
159 | |
---|
160 | G4bool(G4ProcessManager::*f1_GetProcessActivation)(G4VProcess*) const |
---|
161 | = &G4ProcessManager::GetProcessActivation; |
---|
162 | |
---|
163 | G4bool(G4ProcessManager::*f2_GetProcessActivation)(G4int) const |
---|
164 | = &G4ProcessManager::GetProcessActivation; |
---|
165 | |
---|
166 | }; |
---|
167 | |
---|
168 | using namespace pyG4ProcessManager; |
---|
169 | |
---|
170 | // ==================================================================== |
---|
171 | // module definition |
---|
172 | // ==================================================================== |
---|
173 | void export_G4ProcessManager() |
---|
174 | { |
---|
175 | class_<G4ProcessManager, G4ProcessManager*, boost::noncopyable> |
---|
176 | ("G4ProcessManager", "process manager class", no_init) |
---|
177 | // --- |
---|
178 | .def("GetProcessList", f_GetProcessList) |
---|
179 | .def("GetProcessListLength", &G4ProcessManager::GetProcessListLength) |
---|
180 | .def("GetProcessIndex", &G4ProcessManager::GetProcessIndex) |
---|
181 | .def("GetProcessVector", f_GetProcessVector, |
---|
182 | g_GetProcessVector()) |
---|
183 | .def("GetAtRestProcessVector", f_GetAtRestProcessVector, |
---|
184 | g_GetAtRestProcessVector()) |
---|
185 | .def("GetAlongStepProcessVector", f_GetAlongStepProcessVector, |
---|
186 | g_GetAlongStepProcessVector()) |
---|
187 | .def("GetPostStepProcessVector", f_GetPostStepProcessVector, |
---|
188 | g_GetPostStepProcessVector()) |
---|
189 | .def("GetProcessVectorIndex", |
---|
190 | &G4ProcessManager::GetProcessVectorIndex, |
---|
191 | f_GetProcessVectorIndex()) |
---|
192 | .def("GetAtRestIndex", &G4ProcessManager::GetAtRestIndex, |
---|
193 | f_GetAtRestIndex()) |
---|
194 | .def("GetAlongStepIndex", &G4ProcessManager::GetAlongStepIndex, |
---|
195 | f_GetAlongStepIndex()) |
---|
196 | .def("GetPostStepIndex", &G4ProcessManager::GetPostStepIndex, |
---|
197 | f_GetPostStepIndex()) |
---|
198 | // ---- |
---|
199 | .def("AddProcess", &G4ProcessManager::AddProcess, |
---|
200 | f_AddProcess()) |
---|
201 | .def("AddRestProcess", &G4ProcessManager::AddRestProcess, |
---|
202 | f_AddRestProcess()) |
---|
203 | .def("AddDiscreteProcess", &G4ProcessManager::AddDiscreteProcess, |
---|
204 | f_AddDiscreteProcess()) |
---|
205 | .def("AddContinuousProcess", &G4ProcessManager::AddContinuousProcess, |
---|
206 | f_AddContinuousProcess()) |
---|
207 | // --- |
---|
208 | .def("GetProcessOrdering", &G4ProcessManager::GetProcessOrdering) |
---|
209 | .def("SetProcessOrdering", &G4ProcessManager::SetProcessOrdering, |
---|
210 | f_SetProcessOrdering()) |
---|
211 | .def("SetProcessOrderingToFirst", |
---|
212 | &G4ProcessManager::SetProcessOrderingToFirst) |
---|
213 | .def("SetProcessOrderingToLast", |
---|
214 | &G4ProcessManager::SetProcessOrderingToLast) |
---|
215 | // --- |
---|
216 | .def("RemoveProcess", f1_RemoveProcess, |
---|
217 | return_value_policy<reference_existing_object>()) |
---|
218 | .def("RemoveProcess", f2_RemoveProcess, |
---|
219 | return_value_policy<reference_existing_object>()) |
---|
220 | // --- |
---|
221 | .def("SetProcessActivation", f1_SetProcessActivation, |
---|
222 | return_value_policy<reference_existing_object>()) |
---|
223 | .def("SetProcessActivation", f2_SetProcessActivation, |
---|
224 | return_value_policy<reference_existing_object>()) |
---|
225 | .def("GetProcessActivation", f1_GetProcessActivation) |
---|
226 | .def("GetProcessActivation", f2_GetProcessActivation) |
---|
227 | // --- |
---|
228 | .def("GetParticleType", &G4ProcessManager::GetParticleType, |
---|
229 | return_internal_reference<>()) |
---|
230 | .def("SetParticleType", &G4ProcessManager::SetParticleType) |
---|
231 | .def("DumpInfo", &G4ProcessManager::DumpInfo) |
---|
232 | .def("SetVerboseLevel", &G4ProcessManager::SetVerboseLevel) |
---|
233 | .def("GetVerboseLevel", &G4ProcessManager::GetVerboseLevel) |
---|
234 | ; |
---|
235 | |
---|
236 | // enums... |
---|
237 | enum_<G4ProcessVectorTypeIndex>("G4ProcessVectorTypeIndex") |
---|
238 | .value("typeGPIL", typeGPIL) |
---|
239 | .value("typeGPIL", typeDoIt) |
---|
240 | ; |
---|
241 | |
---|
242 | enum_<G4ProcessVectorDoItIndex>("G4ProcessVectorDoItIndex") |
---|
243 | .value("idxAll", idxAll) |
---|
244 | .value("idxAtRest", idxAtRest) |
---|
245 | .value("idxAlongStep", idxAlongStep) |
---|
246 | .value("idxPostStep", idxPostStep) |
---|
247 | ; |
---|
248 | |
---|
249 | enum_<G4ProcessVectorOrdering>("G4ProcessVectorOrdering") |
---|
250 | .value("ordInActive", ordInActive) |
---|
251 | .value("ordDefault", ordDefault) |
---|
252 | .value("ordLast", ordLast) |
---|
253 | ; |
---|
254 | } |
---|