Geant4.10
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
test09.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: test09.cc 66892 2013-01-17 10:57:59Z gunter $
27 // ====================================================================
28 // test09.cc
29 //
30 // test for operators
31 //
32 // 2005 Q
33 // ====================================================================
34 #include <iostream>
35 
36 class AClass {
37 private:
38  int ival;
39 
40 public:
41  AClass() :ival(999) { }
42  AClass(int i) :ival(i) { }
43  ~AClass() { }
44 
45  void SetIVal(int i) { ival= i; }
46  int GetIVal() const { return ival; }
47 
48  AClass operator+(const AClass& aclass) {
49  AClass atemp;
50  atemp.ival= ival + aclass.ival;
51  return atemp;
52  }
53 
54  AClass& operator+=(const AClass& aclass) {
55  ival+= aclass.ival;
56  return *this;
57  }
58 
59  bool operator==(const AClass& aclass) const {
60  if(ival == aclass.ival) return true;
61  return false;
62  }
63 };
64 
65 std::ostream& operator<<(std::ostream& ostr, const AClass& aclass)
66 {
67  return ostr << aclass.GetIVal();
68 }
69 
70 
71 // Boost.Python...
72 #include <boost/python.hpp>
73 
74 using namespace boost::python;
75 
77 {
78  class_<AClass>( "AClass", "a class")
79  .def(init<>())
80  .def(init<int>())
81  .add_property("ival", &AClass::GetIVal, &AClass::SetIVal)
82  .def(self + self)
83  .def(self += self)
84  .def(self == self)
85  .def(self_ns::str(self))
86  ;
87 }
88 
void SetIVal(int i)
Definition: test09.cc:45
AClass()
Definition: test09.cc:41
AClass & operator+=(const AClass &aclass)
Definition: test09.cc:54
~AClass()
Definition: test09.cc:43
bool operator==(const AClass &aclass) const
Definition: test09.cc:59
int GetIVal() const
Definition: test09.cc:46
BOOST_PYTHON_MODULE(test09)
Definition: test09.cc:76
AClass operator+(const AClass &aclass)
Definition: test09.cc:48
std::ostream & operator<<(std::ostream &, const BasicVector3D< float > &)
AClass(int i)
Definition: test09.cc:42