LArSoft
v07_13_02
Liquid Argon Software toolkit - http://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
// $Id: test12.cc 86624 2014-11-14 08:59:40Z kmura $
27
// ====================================================================
28
// test12.cc
29
//
30
// test for indexing a STL vector
31
//
32
// 2005 Q
33
// ====================================================================
34
#include <boost/python.hpp>
35
#if BOOST_VERSION < 103300
36
#include "
vector_indexing_suite.hpp
"
37
#else
38
#include <boost/python/suite/indexing/vector_indexing_suite.hpp>
39
#endif
40
41
#include <vector>
42
#include <iostream>
43
44
class
AClass
{
45
private
:
46
int
ival
;
47
48
public
:
49
AClass
() : ival(0) {
50
}
51
52
AClass
(
const
AClass
&
right
) {
53
ival= right.
ival
;
54
std::cout <<
"*** copy constructor is called"
<< std::endl;
55
}
56
57
~AClass
() { }
58
59
void
SetIVal
(
int
i) { ival= i; }
60
int
GetIVal
() {
return
ival
; }
61
62
void
Print
()
const
{
63
std::cout <<
"*** @"
<<
this
<<
": i="
64
<< ival << std::endl;
65
}
66
67
};
68
69
typedef
std::vector<AClass*>
AVector
;
70
71
72
void
PrintVector
(
const
AVector
& vec) {
73
std::cout <<
"*** size of AVector= "
<< vec.size() << std::endl;
74
for
(
int
i=0; i< vec.size(); i++) {
75
vec[i]->
Print
();
76
}
77
}
78
79
80
// Boost.Python...
81
82
using namespace
boost::python
;
83
84
BOOST_PYTHON_MODULE
(test12)
85
{
86
class_<AClass, AClass*>(
"AClass"
,
"a class"
)
87
.add_property(
"ival"
, &
AClass::GetIVal
, &
AClass::SetIVal
)
88
.def(
"Print"
, &
AClass::Print
)
89
;
90
91
class_<AVector> (
"AVector"
,
"AClass vector"
)
92
.def(
vector_indexing_suite<AVector>
())
93
;
94
95
def(
"PrintVector"
,
PrintVector
);
96
}
97
AClass::ival
int ival
Definition:
AClass.hh:43
AClass::GetIVal
int GetIVal()
Definition:
test12.cc:60
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:112
AClass::~AClass
~AClass()
Definition:
test12.cc:57
AClass::GetIVal
int GetIVal() const
Definition:
AClass.hh:67
AClass::Print
void Print() const
Definition:
test12.cc:62
AClass::AClass
AClass()
Definition:
test12.cc:49
AVector
std::vector< AClass * > AVector
Definition:
test12.cc:69
PrintVector
void PrintVector(const AVector &vec)
Definition:
test12.cc:72
AClass::AClass
AClass(const AClass &right)
Definition:
test12.cc:52
vector_indexing_suite.hpp
BOOST_PYTHON_MODULE
BOOST_PYTHON_MODULE(test12)
Definition:
test12.cc:84
AClass::SetIVal
void SetIVal(int i)
Definition:
test12.cc:59
AClass
Definition:
AClass.hh:41
boost::python::vector_indexing_suite
Definition:
vector_indexing_suite.hpp:17
boost::python
Definition:
container_utils.hpp:14
geant4.10.03.p03
environments
g4py
tests
test12
module
test12.cc
Generated on Wed Dec 12 2018 14:42:37 for LArSoft by
1.8.11