Import Geant4 10.1.0 source tree
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
# - build test library
|
||||
|
||||
include_directories(
|
||||
${PYTHON_INCLUDE_PATH}
|
||||
${Boost_INCLUDE_DIRS}
|
||||
)
|
||||
|
||||
link_directories(${Boost_LIBRARY_DIRS})
|
||||
|
||||
# library
|
||||
set(_TARGET test06)
|
||||
add_library(
|
||||
${_TARGET} SHARED
|
||||
XBase.cc
|
||||
ZBase.cc
|
||||
test06.cc
|
||||
)
|
||||
|
||||
set_target_properties(${_TARGET} PROPERTIES PREFIX "")
|
||||
set_target_properties(${_TARGET} PROPERTIES OUTPUT_NAME "test06")
|
||||
set_target_properties(${_TARGET} PROPERTIES SUFFIX ".so")
|
||||
|
||||
|
||||
target_link_libraries (${_TARGET} boost_python ${PYTHON_LIBRARIES})
|
||||
|
||||
# install
|
||||
install(TARGETS ${_TARGET} LIBRARY DESTINATION ${TEST_MODULES_INSTALL_DIR})
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * License and Disclaimer *
|
||||
// * *
|
||||
// * The Geant4 software is copyright of the Copyright Holders of *
|
||||
// * the Geant4 Collaboration. It is provided under the terms and *
|
||||
// * conditions of the Geant4 Software License, included in the file *
|
||||
// * LICENSE and available at http://cern.ch/geant4/license . These *
|
||||
// * include a list of copyright holders. *
|
||||
// * *
|
||||
// * Neither the authors of this software system, nor their employing *
|
||||
// * institutes,nor the agencies providing financial support for this *
|
||||
// * work make any representation or warranty, express or implied, *
|
||||
// * regarding this software system or assume any liability for its *
|
||||
// * use. Please see the license in the file LICENSE and URL above *
|
||||
// * for the full disclaimer and the limitation of liability. *
|
||||
// * *
|
||||
// * This code implementation is the result of the scientific and *
|
||||
// * technical work of the GEANT4 collaboration. *
|
||||
// * By using, copying, modifying or distributing the software (or *
|
||||
// * any work based on the software) you agree to acknowledge its *
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id: XBase.cc 86749 2014-11-17 15:03:05Z gcosmo $
|
||||
// ====================================================================
|
||||
// XBase.cc
|
||||
//
|
||||
// 2005 Q
|
||||
// ====================================================================
|
||||
#include "XBase.hh"
|
||||
#include <iostream>
|
||||
|
||||
// ====================================================================
|
||||
//
|
||||
// class description
|
||||
//
|
||||
// ====================================================================
|
||||
|
||||
//////////////
|
||||
XBase::XBase()
|
||||
: ival(100)
|
||||
//////////////
|
||||
{
|
||||
}
|
||||
|
||||
///////////////
|
||||
XBase::~XBase()
|
||||
///////////////
|
||||
{
|
||||
}
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * License and Disclaimer *
|
||||
// * *
|
||||
// * The Geant4 software is copyright of the Copyright Holders of *
|
||||
// * the Geant4 Collaboration. It is provided under the terms and *
|
||||
// * conditions of the Geant4 Software License, included in the file *
|
||||
// * LICENSE and available at http://cern.ch/geant4/license . These *
|
||||
// * include a list of copyright holders. *
|
||||
// * *
|
||||
// * Neither the authors of this software system, nor their employing *
|
||||
// * institutes,nor the agencies providing financial support for this *
|
||||
// * work make any representation or warranty, express or implied, *
|
||||
// * regarding this software system or assume any liability for its *
|
||||
// * use. Please see the license in the file LICENSE and URL above *
|
||||
// * for the full disclaimer and the limitation of liability. *
|
||||
// * *
|
||||
// * This code implementation is the result of the scientific and *
|
||||
// * technical work of the GEANT4 collaboration. *
|
||||
// * By using, copying, modifying or distributing the software (or *
|
||||
// * any work based on the software) you agree to acknowledge its *
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id: XBase.hh 86749 2014-11-17 15:03:05Z gcosmo $
|
||||
// ====================================================================
|
||||
// XBase.hh
|
||||
//
|
||||
// 2005 Q
|
||||
// ====================================================================
|
||||
#ifndef XBASE_H
|
||||
#define XBASE_H
|
||||
|
||||
#include <string>
|
||||
|
||||
// ====================================================================
|
||||
//
|
||||
// class definition
|
||||
//
|
||||
// ====================================================================
|
||||
|
||||
class XBase {
|
||||
protected:
|
||||
int ival;
|
||||
|
||||
public:
|
||||
XBase();
|
||||
virtual ~XBase();
|
||||
|
||||
inline void SetIVal(int i);
|
||||
inline int GetIVal() const;
|
||||
|
||||
virtual std::string PVMethod()=0;
|
||||
|
||||
};
|
||||
|
||||
// ====================================================================
|
||||
// inline functions
|
||||
// ====================================================================
|
||||
|
||||
inline void XBase::SetIVal(int i) { ival= i; }
|
||||
inline int XBase::GetIVal() const { return ival; }
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,68 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * License and Disclaimer *
|
||||
// * *
|
||||
// * The Geant4 software is copyright of the Copyright Holders of *
|
||||
// * the Geant4 Collaboration. It is provided under the terms and *
|
||||
// * conditions of the Geant4 Software License, included in the file *
|
||||
// * LICENSE and available at http://cern.ch/geant4/license . These *
|
||||
// * include a list of copyright holders. *
|
||||
// * *
|
||||
// * Neither the authors of this software system, nor their employing *
|
||||
// * institutes,nor the agencies providing financial support for this *
|
||||
// * work make any representation or warranty, express or implied, *
|
||||
// * regarding this software system or assume any liability for its *
|
||||
// * use. Please see the license in the file LICENSE and URL above *
|
||||
// * for the full disclaimer and the limitation of liability. *
|
||||
// * *
|
||||
// * This code implementation is the result of the scientific and *
|
||||
// * technical work of the GEANT4 collaboration. *
|
||||
// * By using, copying, modifying or distributing the software (or *
|
||||
// * any work based on the software) you agree to acknowledge its *
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id: ZBase.cc 86749 2014-11-17 15:03:05Z gcosmo $
|
||||
// ====================================================================
|
||||
// ZBase.cc
|
||||
//
|
||||
// 2005 Q
|
||||
// ====================================================================
|
||||
#include "ZBase.hh"
|
||||
#include <iostream>
|
||||
|
||||
// ====================================================================
|
||||
//
|
||||
// class description
|
||||
//
|
||||
// ====================================================================
|
||||
|
||||
//////////////
|
||||
ZBase::ZBase()
|
||||
//////////////
|
||||
{
|
||||
}
|
||||
|
||||
///////////////
|
||||
ZBase::~ZBase()
|
||||
///////////////
|
||||
{
|
||||
}
|
||||
|
||||
/////////////////////
|
||||
void ZBase::AMethod()
|
||||
/////////////////////
|
||||
{
|
||||
std::cout << "ZBase::AMethod is called." << std::endl;
|
||||
}
|
||||
|
||||
////////////////////////////////////////
|
||||
void ZBase::VMethod(std::string message)
|
||||
////////////////////////////////////////
|
||||
{
|
||||
std::cout << "ZBase::VMethod is called:"
|
||||
<< message
|
||||
<< std::endl;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * License and Disclaimer *
|
||||
// * *
|
||||
// * The Geant4 software is copyright of the Copyright Holders of *
|
||||
// * the Geant4 Collaboration. It is provided under the terms and *
|
||||
// * conditions of the Geant4 Software License, included in the file *
|
||||
// * LICENSE and available at http://cern.ch/geant4/license . These *
|
||||
// * include a list of copyright holders. *
|
||||
// * *
|
||||
// * Neither the authors of this software system, nor their employing *
|
||||
// * institutes,nor the agencies providing financial support for this *
|
||||
// * work make any representation or warranty, express or implied, *
|
||||
// * regarding this software system or assume any liability for its *
|
||||
// * use. Please see the license in the file LICENSE and URL above *
|
||||
// * for the full disclaimer and the limitation of liability. *
|
||||
// * *
|
||||
// * This code implementation is the result of the scientific and *
|
||||
// * technical work of the GEANT4 collaboration. *
|
||||
// * By using, copying, modifying or distributing the software (or *
|
||||
// * any work based on the software) you agree to acknowledge its *
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id: ZBase.hh 86749 2014-11-17 15:03:05Z gcosmo $
|
||||
// ====================================================================
|
||||
// ZBase.hh
|
||||
//
|
||||
// 2005 Q
|
||||
// ====================================================================
|
||||
#ifndef ZBASE_H
|
||||
#define ZBASE_H
|
||||
|
||||
#include <string>
|
||||
|
||||
// ====================================================================
|
||||
//
|
||||
// class definition
|
||||
//
|
||||
// ====================================================================
|
||||
|
||||
class ZBase {
|
||||
public:
|
||||
ZBase();
|
||||
virtual ~ZBase();
|
||||
|
||||
void AMethod();
|
||||
virtual void VMethod(std::string message);
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,74 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * License and Disclaimer *
|
||||
// * *
|
||||
// * The Geant4 software is copyright of the Copyright Holders of *
|
||||
// * the Geant4 Collaboration. It is provided under the terms and *
|
||||
// * conditions of the Geant4 Software License, included in the file *
|
||||
// * LICENSE and available at http://cern.ch/geant4/license . These *
|
||||
// * include a list of copyright holders. *
|
||||
// * *
|
||||
// * Neither the authors of this software system, nor their employing *
|
||||
// * institutes,nor the agencies providing financial support for this *
|
||||
// * work make any representation or warranty, express or implied, *
|
||||
// * regarding this software system or assume any liability for its *
|
||||
// * use. Please see the license in the file LICENSE and URL above *
|
||||
// * for the full disclaimer and the limitation of liability. *
|
||||
// * *
|
||||
// * This code implementation is the result of the scientific and *
|
||||
// * technical work of the GEANT4 collaboration. *
|
||||
// * By using, copying, modifying or distributing the software (or *
|
||||
// * any work based on the software) you agree to acknowledge its *
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id: test06.cc 86749 2014-11-17 15:03:05Z gcosmo $
|
||||
// ====================================================================
|
||||
// test06.cc
|
||||
//
|
||||
// test for inheritance
|
||||
// - inherit C++ base class in Python side
|
||||
//
|
||||
// 2005 Q
|
||||
// ====================================================================
|
||||
#include <boost/python.hpp>
|
||||
|
||||
#include "XBase.hh"
|
||||
#include "ZBase.hh"
|
||||
|
||||
using namespace boost::python;
|
||||
|
||||
struct w_XBase : XBase, wrapper<XBase> {
|
||||
std::string PVMethod() {
|
||||
return this-> get_override("PVMethod")();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
struct w_ZBase : ZBase, wrapper<ZBase> {
|
||||
void VMethod(std::string message) {
|
||||
if(override f= this-> get_override("VMethod"))
|
||||
f(message);
|
||||
else
|
||||
ZBase::VMethod(message);
|
||||
}
|
||||
|
||||
void d_VMethod(std::string message) {
|
||||
this-> ZBase::VMethod(message);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
BOOST_PYTHON_MODULE(test06) {
|
||||
//class_<w_XBase, boost::noncopyable>("XBase", "base class", no_init)
|
||||
class_<w_XBase, boost::noncopyable>("XBase", "base class")
|
||||
.add_property("ival", &XBase::GetIVal, &XBase::SetIVal)
|
||||
.def("PVMethod", pure_virtual(&XBase::PVMethod))
|
||||
;
|
||||
|
||||
class_<w_ZBase, boost::noncopyable>("ZBase", "base class")
|
||||
.def("AMethod", &ZBase::AMethod)
|
||||
.def("VMethod", &ZBase::VMethod, &w_ZBase::d_VMethod)
|
||||
;
|
||||
}
|
||||
Reference in New Issue
Block a user