LArSoft
v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
test12.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
// test12.cc
28
//
29
// test for indexing a STL vector
30
//
31
// 2005 Q
32
// ====================================================================
33
#include <boost/python.hpp>
34
#if BOOST_VERSION < 103300
35
#include "
vector_indexing_suite.hpp
"
36
#else
37
#include <boost/python/suite/indexing/vector_indexing_suite.hpp>
38
#endif
39
40
#include <vector>
41
#include <iostream>
42
43
class
AClass
{
44
private
:
45
int
ival
;
46
47
public
:
48
AClass
() : ival(0) {
49
}
50
51
AClass
(
const
AClass
&
right
) {
52
ival= right.
ival
;
53
std::cout <<
"*** copy constructor is called"
<< std::endl;
54
}
55
56
~AClass
() { }
57
58
void
SetIVal
(
int
i) { ival= i; }
59
int
GetIVal
() {
return
ival
; }
60
61
void
Print
()
const
{
62
std::cout <<
"*** @"
<<
this
<<
": i="
63
<< ival << std::endl;
64
}
65
66
};
67
68
typedef
std::vector<AClass*>
AVector
;
69
70
71
void
PrintVector
(
const
AVector
& vec) {
72
std::cout <<
"*** size of AVector= "
<< vec.size() << std::endl;
73
for
(
int
i=0; i< vec.size(); i++) {
74
vec[i]->
Print
();
75
}
76
}
77
78
79
// Boost.Python...
80
81
using namespace
boost::python
;
82
83
BOOST_PYTHON_MODULE
(test12)
84
{
85
class_<AClass, AClass*>(
"AClass"
,
"a class"
)
86
.add_property(
"ival"
, &
AClass::GetIVal
, &
AClass::SetIVal
)
87
.def(
"Print"
, &
AClass::Print
)
88
;
89
90
class_<AVector> (
"AVector"
,
"AClass vector"
)
91
.def(
vector_indexing_suite<AVector>
())
92
;
93
94
def(
"PrintVector"
,
PrintVector
);
95
}
96
AClass::ival
int ival
Definition:
AClass.hh:42
AClass::GetIVal
int GetIVal()
Definition:
test12.cc:59
art::right
constexpr auto const & right(const_AssnsIter< L, R, D, Dir > const &a, const_AssnsIter< L, R, D, Dir > const &b)
Definition:
AssnsIter.h:102
AClass::~AClass
~AClass()
Definition:
test12.cc:56
AClass::GetIVal
int GetIVal() const
Definition:
AClass.hh:66
AClass::Print
void Print() const
Definition:
test12.cc:61
AClass::AClass
AClass()
Definition:
test12.cc:48
AVector
std::vector< AClass * > AVector
Definition:
test12.cc:68
PrintVector
void PrintVector(const AVector &vec)
Definition:
test12.cc:71
AClass::AClass
AClass(const AClass &right)
Definition:
test12.cc:51
vector_indexing_suite.hpp
BOOST_PYTHON_MODULE
BOOST_PYTHON_MODULE(test12)
Definition:
test12.cc:83
AClass::SetIVal
void SetIVal(int i)
Definition:
test12.cc:58
AClass
Definition:
AClass.hh:40
boost::python::vector_indexing_suite
Definition:
vector_indexing_suite.hpp:17
boost::python
Definition:
container_utils.hpp:14
geant4.10.06.p01
environments
g4py
tests
test12
module
test12.cc
Generated on Thu May 2 2024 20:59:32 for LArSoft by
1.8.11