diff --git a/App/inc/FunctionalTestFactory.h b/App/inc/FunctionalTestFactory.h index 8b7dd7e82e5d3a70cfdedf24386a047e091d6e13..a3265304f7701c684badb4f52bdab419ef438a3f 100644 --- a/App/inc/FunctionalTestFactory.h +++ b/App/inc/FunctionalTestFactory.h @@ -46,9 +46,6 @@ public: //! Prints benchmark summary void print_benchmarks(); - iterator begin() { return m_descriptions.begin(); } - iterator end() { return m_descriptions.end(); } - private: TBenchmark *m_benchmark; }; diff --git a/App/src/TestMiscellaneous.cpp b/App/src/TestMiscellaneous.cpp index 1ee9a8fd993a0340fb4959d462555c11707a3919..b3d55e6d0fd77166ae6ecfcff0ba387236f9ab76 100644 --- a/App/src/TestMiscellaneous.cpp +++ b/App/src/TestMiscellaneous.cpp @@ -81,12 +81,14 @@ void TestMiscellaneous::test_PrintVisitor() { std::cout << "TestMiscellaneous::test_PrintVisitor() ->" << std::endl; SampleBuilderFactory factory; - ISample *sample = factory.createSample("isgisaxs04_2DDL"); - //std::cout << (*sample) << std::endl; - sample->printSampleTree(); - //SamplePrintVisitor visitor; - //sample->accept(&visitor); + for(SampleBuilderFactory::iterator it = factory.begin(); it!= factory.end(); ++it) { + ISample *sample = factory.createSample((*it).first); + std::cout << std::endl << ">>> " << (*it).first << " <<<" << std::endl; + sample->printSampleTree(); + delete sample; + } + } diff --git a/Core/PythonAPI/src/IClusteredParticles.pypp.cpp b/Core/PythonAPI/src/IClusteredParticles.pypp.cpp index dbd80633145ffbf03b3ed3ab1ee3940d641779d8..af2482e61f60eef51e5512b644eabe9f9424a6c5 100644 --- a/Core/PythonAPI/src/IClusteredParticles.pypp.cpp +++ b/Core/PythonAPI/src/IClusteredParticles.pypp.cpp @@ -25,28 +25,19 @@ struct IClusteredParticles_wrapper : IClusteredParticles, bp::wrapper< IClustere } - virtual ::IClusteredParticles * clone( ) const { - if( bp::override func_clone = this->get_override( "clone" ) ) - return func_clone( ); - else - return this->IClusteredParticles::clone( ); - } - - - ::IClusteredParticles * default_clone( ) const { - return IClusteredParticles::clone( ); + virtual void accept( ::ISampleVisitor * visitor ) const { + bp::override func_accept = this->get_override( "accept" ); + func_accept( boost::python::ptr(visitor) ); } - virtual ::IClusteredParticles * cloneInvertB( ) const { - if( bp::override func_cloneInvertB = this->get_override( "cloneInvertB" ) ) - return func_cloneInvertB( ); - else - return this->IClusteredParticles::cloneInvertB( ); + virtual ::IClusteredParticles * clone( ) const { + bp::override func_clone = this->get_override( "clone" ); + return func_clone( ); } - - - ::IClusteredParticles * default_cloneInvertB( ) const { - return IClusteredParticles::cloneInvertB( ); + + virtual ::IClusteredParticles * cloneInvertB( ) const { + bp::override func_cloneInvertB = this->get_override( "cloneInvertB" ); + return func_cloneInvertB( ); } virtual ::Geometry::ITransform3D const * getTransform( ) const { @@ -78,11 +69,6 @@ struct IClusteredParticles_wrapper : IClusteredParticles, bp::wrapper< IClustere IClusteredParticles::setTransform( boost::ref(transform) ); } - virtual void accept( ::ISampleVisitor * p_visitor ) const { - bp::override func_accept = this->get_override( "accept" ); - func_accept( boost::python::ptr(p_visitor) ); - } - virtual bool areParametersChanged( ) { if( bp::override func_areParametersChanged = this->get_override( "areParametersChanged" ) ) return func_areParametersChanged( ); @@ -242,27 +228,33 @@ void register_IClusteredParticles_class(){ typedef bp::class_< IClusteredParticles_wrapper, bp::bases< ICompositeSample >, boost::noncopyable > IClusteredParticles_exposer_t; IClusteredParticles_exposer_t IClusteredParticles_exposer = IClusteredParticles_exposer_t( "IClusteredParticles", bp::init< >() ); bp::scope IClusteredParticles_scope( IClusteredParticles_exposer ); + { //::IClusteredParticles::accept + + typedef void ( ::IClusteredParticles::*accept_function_type )( ::ISampleVisitor * ) const; + + IClusteredParticles_exposer.def( + "accept" + , bp::pure_virtual( accept_function_type(&::IClusteredParticles::accept) ) + , ( bp::arg("visitor") ) ); + + } { //::IClusteredParticles::clone typedef ::IClusteredParticles * ( ::IClusteredParticles::*clone_function_type )( ) const; - typedef ::IClusteredParticles * ( IClusteredParticles_wrapper::*default_clone_function_type )( ) const; IClusteredParticles_exposer.def( "clone" - , clone_function_type(&::IClusteredParticles::clone) - , default_clone_function_type(&IClusteredParticles_wrapper::default_clone) + , bp::pure_virtual( clone_function_type(&::IClusteredParticles::clone) ) , bp::return_value_policy< bp::manage_new_object >() ); } { //::IClusteredParticles::cloneInvertB typedef ::IClusteredParticles * ( ::IClusteredParticles::*cloneInvertB_function_type )( ) const; - typedef ::IClusteredParticles * ( IClusteredParticles_wrapper::*default_cloneInvertB_function_type )( ) const; IClusteredParticles_exposer.def( "cloneInvertB" - , cloneInvertB_function_type(&::IClusteredParticles::cloneInvertB) - , default_cloneInvertB_function_type(&IClusteredParticles_wrapper::default_cloneInvertB) + , bp::pure_virtual( cloneInvertB_function_type(&::IClusteredParticles::cloneInvertB) ) , bp::return_value_policy< bp::reference_existing_object >() ); } @@ -299,16 +291,6 @@ void register_IClusteredParticles_class(){ , default_setTransform_function_type(&IClusteredParticles_wrapper::default_setTransform) , ( bp::arg("transform") ) ); - } - { //::ISample::accept - - typedef void ( ::ISample::*accept_function_type )( ::ISampleVisitor * ) const; - - IClusteredParticles_exposer.def( - "accept" - , bp::pure_virtual( accept_function_type(&::ISample::accept) ) - , ( bp::arg("p_visitor") ) ); - } { //::IParameterized::areParametersChanged diff --git a/Core/PythonAPI/src/ICompositeSample.pypp.cpp b/Core/PythonAPI/src/ICompositeSample.pypp.cpp index 10f89768880888ddbc755621b4b9b3d0d9aafbc7..981cc0b493f661ce0a999962998da1c0df9405ae 100644 --- a/Core/PythonAPI/src/ICompositeSample.pypp.cpp +++ b/Core/PythonAPI/src/ICompositeSample.pypp.cpp @@ -66,11 +66,6 @@ struct ICompositeSample_wrapper : ICompositeSample, bp::wrapper< ICompositeSampl return ICompositeSample::size( ); } - virtual void accept( ::ISampleVisitor * p_visitor ) const { - bp::override func_accept = this->get_override( "accept" ); - func_accept( boost::python::ptr(p_visitor) ); - } - virtual bool areParametersChanged( ) { if( bp::override func_areParametersChanged = this->get_override( "areParametersChanged" ) ) return func_areParametersChanged( ); @@ -286,16 +281,6 @@ void register_ICompositeSample_class(){ , size_function_type(&::ICompositeSample::size) , default_size_function_type(&ICompositeSample_wrapper::default_size) ); - } - { //::ISample::accept - - typedef void ( ::ISample::*accept_function_type )( ::ISampleVisitor * ) const; - - ICompositeSample_exposer.def( - "accept" - , bp::pure_virtual( accept_function_type(&::ISample::accept) ) - , ( bp::arg("p_visitor") ) ); - } { //::IParameterized::areParametersChanged diff --git a/Core/PythonAPI/src/IDecoration.pypp.cpp b/Core/PythonAPI/src/IDecoration.pypp.cpp index 4cbc743d39b703660f81b897c0f55d561a2bce23..dbc89fb2548653bb19db049911e57fac3b68697a 100644 --- a/Core/PythonAPI/src/IDecoration.pypp.cpp +++ b/Core/PythonAPI/src/IDecoration.pypp.cpp @@ -25,6 +25,11 @@ struct IDecoration_wrapper : IDecoration, bp::wrapper< IDecoration > { } + virtual void accept( ::ISampleVisitor * visitor ) const { + bp::override func_accept = this->get_override( "accept" ); + func_accept( boost::python::ptr(visitor) ); + } + virtual ::IDecoration * clone( ) const { bp::override func_clone = this->get_override( "clone" ); return func_clone( ); @@ -67,11 +72,6 @@ struct IDecoration_wrapper : IDecoration, bp::wrapper< IDecoration > { return func_getParticleInfo( index ); } - virtual void accept( ::ISampleVisitor * p_visitor ) const { - bp::override func_accept = this->get_override( "accept" ); - func_accept( boost::python::ptr(p_visitor) ); - } - virtual bool areParametersChanged( ) { if( bp::override func_areParametersChanged = this->get_override( "areParametersChanged" ) ) return func_areParametersChanged( ); @@ -231,6 +231,16 @@ void register_IDecoration_class(){ typedef bp::class_< IDecoration_wrapper, bp::bases< ICompositeSample >, boost::noncopyable > IDecoration_exposer_t; IDecoration_exposer_t IDecoration_exposer = IDecoration_exposer_t( "IDecoration", bp::init< >() ); bp::scope IDecoration_scope( IDecoration_exposer ); + { //::IDecoration::accept + + typedef void ( ::IDecoration::*accept_function_type )( ::ISampleVisitor * ) const; + + IDecoration_exposer.def( + "accept" + , bp::pure_virtual( accept_function_type(&::IDecoration::accept) ) + , ( bp::arg("visitor") ) ); + + } { //::IDecoration::clone typedef ::IDecoration * ( ::IDecoration::*clone_function_type )( ) const; @@ -319,16 +329,6 @@ void register_IDecoration_class(){ , setTotalParticleSurfaceDensity_function_type( &::IDecoration::setTotalParticleSurfaceDensity ) , ( bp::arg("surface_density") ) ); - } - { //::ISample::accept - - typedef void ( ::ISample::*accept_function_type )( ::ISampleVisitor * ) const; - - IDecoration_exposer.def( - "accept" - , bp::pure_virtual( accept_function_type(&::ISample::accept) ) - , ( bp::arg("p_visitor") ) ); - } { //::IParameterized::areParametersChanged diff --git a/Core/Samples/inc/Crystal.h b/Core/Samples/inc/Crystal.h index c153e38ee6f52576ad17ac1cef5f4ea4bf633875..f842e5160443fabe67b203da8faa0054514af771 100644 --- a/Core/Samples/inc/Crystal.h +++ b/Core/Samples/inc/Crystal.h @@ -35,7 +35,7 @@ public: virtual Crystal *cloneInvertB() const; //! Calls the ISampleVisitor's visit method - virtual void accept(ISampleVisitor *p_visitor) const { p_visitor->visit(this); } + virtual void accept(ISampleVisitor *visitor) const { visitor->visit(this); } virtual void setAmbientMaterial(const IMaterial *p_ambient_material) { mp_lattice_basis->setAmbientMaterial(p_ambient_material); } diff --git a/Core/Samples/inc/IClusteredParticles.h b/Core/Samples/inc/IClusteredParticles.h index 2b73a4acd155f3727fc42e087d2663d6534d68e5..af2bb55f135fa702c19dacfb7193b3f653ceb3cb 100644 --- a/Core/Samples/inc/IClusteredParticles.h +++ b/Core/Samples/inc/IClusteredParticles.h @@ -29,19 +29,17 @@ class BA_CORE_API_ IClusteredParticles : public ICompositeSample public: IClusteredParticles() {} virtual ~IClusteredParticles() {} + //! clone method to allow for polymorphic copying - virtual IClusteredParticles *clone() const { - throw NotImplementedException("IClusteredParticles::clone() -> Error! " - "Not implemented exception"); - } + virtual IClusteredParticles *clone() const = 0; //! Returns a clone with inverted magnetic fields - virtual IClusteredParticles *cloneInvertB() const { - throw NotImplementedException("IClusteredParticles::cloneInvertB() -> " - "Error! Not implemented exception"); - } + virtual IClusteredParticles *cloneInvertB() const = 0; + + //! calls the ISampleVisitor's visit method + virtual void accept(ISampleVisitor *visitor) const = 0; - virtual void setAmbientMaterial(const IMaterial *p_ambient_material)=0; + virtual void setAmbientMaterial(const IMaterial *p_ambient_material) = 0; //! @brief create a total form factor for the mesocrystal with a specific //! shape and content diff --git a/Core/Samples/inc/ICompositeSample.h b/Core/Samples/inc/ICompositeSample.h index b6e7f7cee045b5a2c8f4bccf2d5053ae15df3994..bd2e4b39438c59619a7f7058716abb03a0b3d132 100644 --- a/Core/Samples/inc/ICompositeSample.h +++ b/Core/Samples/inc/ICompositeSample.h @@ -32,6 +32,9 @@ public: ICompositeSample *clone() const = 0; + //! calls the ISampleVisitor's visit method + virtual void accept(ISampleVisitor *visitor) const { visitor->visit(this); } + //! to confirm compound nature of given class virtual ICompositeSample *getCompositeSample() { return this; } virtual const ICompositeSample *getCompositeSample() const { return this; } diff --git a/Core/Samples/inc/IDecoration.h b/Core/Samples/inc/IDecoration.h index 1eada6501ce984db4db9b97f8c5bc04222968356..0fcfdd1163062a9cb618072387a263af2712ef7e 100644 --- a/Core/Samples/inc/IDecoration.h +++ b/Core/Samples/inc/IDecoration.h @@ -34,6 +34,9 @@ public: virtual IDecoration *clone() const=0; + //! calls the ISampleVisitor's visit method + virtual void accept(ISampleVisitor *visitor) const=0; + //! Returns a clone with inverted magnetic fields virtual IDecoration *cloneInvertB() const=0; diff --git a/Core/Samples/inc/LatticeBasis.h b/Core/Samples/inc/LatticeBasis.h index 2433058cc8aad838dc2278dc516c973a6c992925..04670cbe9b3eee0250280db6b8cbc1fc0ddb91bf 100644 --- a/Core/Samples/inc/LatticeBasis.h +++ b/Core/Samples/inc/LatticeBasis.h @@ -36,9 +36,7 @@ public: LatticeBasis *createTransformed() const; //! Calls the ISampleVisitor's visit method - virtual void accept(ISampleVisitor *p_visitor) const { - p_visitor->visit(this); - } + virtual void accept(ISampleVisitor *visitor) const { visitor->visit(this); } void addParticle(const Particle& particle, std::vector<kvector_t > positions); diff --git a/Core/Samples/inc/Layer.h b/Core/Samples/inc/Layer.h index 8ac57404f0a3f13f4918a2f8ad755927486272ca..38d7f9cb655d6b6ffbb65841530e2bfab5dcff49 100644 --- a/Core/Samples/inc/Layer.h +++ b/Core/Samples/inc/Layer.h @@ -43,7 +43,7 @@ public: virtual Layer *cloneInvertB() const; //! Calls the ISampleVisitor's visit method - virtual void accept(ISampleVisitor *p_visitor) const { p_visitor->visit(this); } + virtual void accept(ISampleVisitor *visitor) const { visitor->visit(this); } //! Sets layer thickness in nanometers. virtual void setThickness(double thickness); diff --git a/Core/Samples/inc/MesoCrystal.h b/Core/Samples/inc/MesoCrystal.h index ef9291797b8c97ad46f76ce616af7edd74cf4e5f..4d83862a083ac716bbb3202d9f92c5459f745681 100644 --- a/Core/Samples/inc/MesoCrystal.h +++ b/Core/Samples/inc/MesoCrystal.h @@ -37,9 +37,7 @@ public: virtual MesoCrystal *cloneInvertB() const; //! Calls the ISampleVisitor's visit method - virtual void accept(ISampleVisitor *p_visitor) const { - p_visitor->visit(this); - } + virtual void accept(ISampleVisitor *visitor) const { visitor->visit(this); } virtual void setAmbientMaterial(const IMaterial *p_material); diff --git a/Core/Samples/inc/ParticleCoreShell.h b/Core/Samples/inc/ParticleCoreShell.h index eb15497bc6f0e0fa9f4f3c3c4d8e635d8530d08d..057fd89579017faec5f992866e84518f7f256a36 100644 --- a/Core/Samples/inc/ParticleCoreShell.h +++ b/Core/Samples/inc/ParticleCoreShell.h @@ -32,9 +32,7 @@ public: virtual ParticleCoreShell *cloneInvertB() const; //! Calls the ISampleVisitor's visit method - virtual void accept(ISampleVisitor *p_visitor) const { - p_visitor->visit(this); - } + virtual void accept(ISampleVisitor *visitor) const { visitor->visit(this); } //! Sets the refractive index of the ambient material (which influences //! its scattering power) diff --git a/Core/Tools/inc/IFactory.h b/Core/Tools/inc/IFactory.h index 875809c891311cc5b2c16a2130879986962c3a9a..d3fedeb6d66ab21bac8fc35dad4976cb72262a7c 100644 --- a/Core/Tools/inc/IFactory.h +++ b/Core/Tools/inc/IFactory.h @@ -101,6 +101,13 @@ public: //! Returns number of registered objects size_t getNumberOfRegistered() const { return m_callbacks.size(); } + iterator begin() { return m_descriptions.begin(); } + const_iterator begin() const { return m_descriptions.begin(); } + + iterator end() { return m_descriptions.end(); } + const_iterator end() const { return m_descriptions.end(); } + + protected: bool m_own_objects; //!< will store created objects in the list and then delete them on exit then true CallbackMap_t m_callbacks; //!< map of correspondance of objectsId and creation functions diff --git a/Core/Tools/inc/SamplePrintVisitor.h b/Core/Tools/inc/SamplePrintVisitor.h index cf08a1bc55b63df3a2b7c160c537727b47ccc20c..f24b07da66cece1a6686b096721b608be8fc3fdf 100644 --- a/Core/Tools/inc/SamplePrintVisitor.h +++ b/Core/Tools/inc/SamplePrintVisitor.h @@ -85,13 +85,8 @@ public: virtual void visit(const LayerRoughness *sample); private: - std::string get_indent() - { - std::string result; - result.resize(getLevel()*4, '.'); - result += " "; - return result; - } + std::string get_indent(); + void print_default(const ISample *sample); }; diff --git a/Core/Tools/src/SamplePrintVisitor.cpp b/Core/Tools/src/SamplePrintVisitor.cpp index 0342640f3285cae17031956264a00c89409de029..aed28f8c9a95cf7f4a120ec4cad015cd05c1b90b 100644 --- a/Core/Tools/src/SamplePrintVisitor.cpp +++ b/Core/Tools/src/SamplePrintVisitor.cpp @@ -5,10 +5,9 @@ #include "ParticleDecoration.h" #include "Particle.h" #include "ParticleCoreShell.h" -#include "InterferenceFunction1DParaCrystal.h" -#include "InterferenceFunction2DParaCrystal.h" -#include "InterferenceFunction2DLattice.h" +#include "InterferenceFunctions.h" #include "ParticleInfo.h" +#include "LayerInterface.h" #include <iostream> #include "MesoCrystal.h" @@ -45,10 +44,7 @@ void SamplePrintVisitor::visit(const IDecoration *) void SamplePrintVisitor::visit(const ParticleDecoration *sample) { - assert(sample); - std::cout << get_indent() << "ParticleDecoration " << sample->getName() - << " " << (*sample->getParameterPool()) - << std::endl; + print_default(sample); } @@ -63,9 +59,9 @@ void SamplePrintVisitor::visit(const Layer *sample) } -void SamplePrintVisitor::visit(const LayerInterface *) +void SamplePrintVisitor::visit(const LayerInterface *sample) { - throw NotImplementedException("SamplePrintVisitor::visit(const LayerInterface *) -> Error. Not implemented."); + print_default(sample); } @@ -73,15 +69,17 @@ void SamplePrintVisitor::visit(const MultiLayer *sample) { assert(sample); std::cout << "--------------------------------------------------------------------------------" << std::endl; - std::cout << get_indent() << sample->getName() - << " " << (*sample->getParameterPool()) - << std::endl; + print_default(sample); } -void SamplePrintVisitor::visit(const Particle *) +void SamplePrintVisitor::visit(const Particle *sample) { - throw NotImplementedException("SamplePrintVisitor::visit(const Particle *) -> Error. Not implemented."); + assert(sample); + std::cout << get_indent() << sample->getName() + << " " << (sample->getMaterial() ? sample->getMaterial()->getName() : "0_MATERIAL") + << " " << sample->getRefractiveIndex() + << std::endl; } @@ -103,9 +101,9 @@ void SamplePrintVisitor::visit(const ParticleCoreShell *) } -void SamplePrintVisitor::visit(const ParticleInfo *) +void SamplePrintVisitor::visit(const ParticleInfo *sample) { - throw NotImplementedException("SamplePrintVisitor::visit(const ParticleInfo *) -> Error. Not implemented."); + print_default(sample); } @@ -151,21 +149,21 @@ void SamplePrintVisitor::visit(const IFormFactorBorn *) } -void SamplePrintVisitor::visit(const FormFactorBox *) +void SamplePrintVisitor::visit(const FormFactorBox *sample) { - throw NotImplementedException("SamplePrintVisitor::visit(const FormFactorBox *) -> Error. Not implemented."); + print_default(sample); } -void SamplePrintVisitor::visit(const FormFactorCone *) +void SamplePrintVisitor::visit(const FormFactorCone *sample) { - throw NotImplementedException("SamplePrintVisitor::visit(const FormFactorCone *) -> Error. Not implemented."); + print_default(sample); } -void SamplePrintVisitor::visit(const FormFactorCone6 *) +void SamplePrintVisitor::visit(const FormFactorCone6 *sample) { - throw NotImplementedException("SamplePrintVisitor::visit(const FormFactorCone6 *) -> Error. Not implemented."); + print_default(sample); } @@ -175,39 +173,39 @@ void SamplePrintVisitor::visit(const FormFactorCrystal *) } -void SamplePrintVisitor::visit(const FormFactorCylinder *) +void SamplePrintVisitor::visit(const FormFactorCylinder *sample) { - throw NotImplementedException("SamplePrintVisitor::visit(const FormFactorCylinder *) -> Error. Not implemented."); + print_default(sample); } -void SamplePrintVisitor::visit(const FormFactorEllipsoid *) +void SamplePrintVisitor::visit(const FormFactorEllipsoid *sample) { - throw NotImplementedException("SamplePrintVisitor::visit(const FormFactorEllipsoid *) -> Error. Not implemented."); + print_default(sample); } -void SamplePrintVisitor::visit(const FormFactorFullSphere *) +void SamplePrintVisitor::visit(const FormFactorFullSphere *sample) { - throw NotImplementedException("SamplePrintVisitor::visit(const FormFactorFullSphere *) -> Error. Not implemented."); + print_default(sample); } -void SamplePrintVisitor::visit(const FormFactorFullSpheroid *) +void SamplePrintVisitor::visit(const FormFactorFullSpheroid *sample) { - throw NotImplementedException("SamplePrintVisitor::visit(const FormFactorFullSpheroid *) -> Error. Not implemented."); + print_default(sample); } -void SamplePrintVisitor::visit(const FormFactorGauss *) +void SamplePrintVisitor::visit(const FormFactorGauss *sample) { - throw NotImplementedException("SamplePrintVisitor::visit(const FormFactorGauss *) -> Error. Not implemented."); + print_default(sample); } -void SamplePrintVisitor::visit(const FormFactorHemiSpheroid *) +void SamplePrintVisitor::visit(const FormFactorHemiSpheroid *sample) { - throw NotImplementedException("SamplePrintVisitor::visit const FormFactorHemiSpheroid *) -> Error. Not implemented."); + print_default(sample); } @@ -217,33 +215,33 @@ void SamplePrintVisitor::visit(const FormFactorLorentz *) } -void SamplePrintVisitor::visit(const FormFactorParallelepiped *) +void SamplePrintVisitor::visit(const FormFactorParallelepiped *sample) { - throw NotImplementedException("SamplePrintVisitor::visit(const FormFactorParallelepiped *) -> Error. Not implemented."); + print_default(sample); } -void SamplePrintVisitor::visit(const FormFactorPrism3 *) +void SamplePrintVisitor::visit(const FormFactorPrism3 *sample) { - throw NotImplementedException("SamplePrintVisitor::visit(const FormFactorPrism3 *) -> Error. Not implemented."); + print_default(sample); } -void SamplePrintVisitor::visit(const FormFactorPrism6 *) +void SamplePrintVisitor::visit(const FormFactorPrism6 *sample) { - throw NotImplementedException("SamplePrintVisitor::visit(const FormFactorPrism6 *) -> Error. Not implemented."); + print_default(sample); } -void SamplePrintVisitor::visit(const FormFactorPyramid *) +void SamplePrintVisitor::visit(const FormFactorPyramid *sample) { - throw NotImplementedException("SamplePrintVisitor::visit(const FormFactorPyramid *) -> Error. Not implemented."); + print_default(sample); } -void SamplePrintVisitor::visit(const FormFactorSphere *) +void SamplePrintVisitor::visit(const FormFactorSphere *sample) { - throw NotImplementedException("SamplePrintVisitor::visit(const FormFactorSphere *) -> Error. Not implemented."); + print_default(sample); } @@ -253,9 +251,9 @@ void SamplePrintVisitor::visit(const FormFactorSphereGaussianRadius *) } -void SamplePrintVisitor::visit(const FormFactorTetrahedron *) +void SamplePrintVisitor::visit(const FormFactorTetrahedron *sample) { - throw NotImplementedException("SamplePrintVisitor::visit(const FormFactorTetrahedron *) -> Error. Not implemented."); + print_default(sample); } @@ -325,26 +323,26 @@ void SamplePrintVisitor::visit(const IInterferenceFunction *) } -void SamplePrintVisitor::visit(const InterferenceFunction1DParaCrystal *){ - throw NotImplementedException("SamplePrintVisitor::visit(const InterferenceFunction1DParaCrystal *) -> Error. Not implemented."); +void SamplePrintVisitor::visit(const InterferenceFunction1DParaCrystal *sample){ + print_default(sample); } -void SamplePrintVisitor::visit(const InterferenceFunction2DLattice *) +void SamplePrintVisitor::visit(const InterferenceFunction2DLattice *sample) { - throw NotImplementedException("SamplePrintVisitor::visit(const InterferenceFunction2DLattice *) -> Error. Not implemented."); + print_default(sample); } -void SamplePrintVisitor::visit(const InterferenceFunction2DParaCrystal *) +void SamplePrintVisitor::visit(const InterferenceFunction2DParaCrystal *sample) { - throw NotImplementedException("SamplePrintVisitor::visit(const InterferenceFunction2DParaCrystal *) -> Error. Not implemented."); + print_default(sample); } -void SamplePrintVisitor::visit(const InterferenceFunctionNone *) +void SamplePrintVisitor::visit(const InterferenceFunctionNone *sample) { - throw NotImplementedException("SamplePrintVisitor::visit(const InterferenceFunctionNone *) -> Error. Not implemented."); + print_default(sample); } @@ -354,11 +352,33 @@ void SamplePrintVisitor::visit(const IRoughness *) } -void SamplePrintVisitor::visit(const LayerRoughness *) +void SamplePrintVisitor::visit(const LayerRoughness *sample) +{ + print_default(sample); +} + + +// ----------------------------------------------------------------------------- +// +// ----------------------------------------------------------------------------- + +//! return string representing indentation +std::string SamplePrintVisitor::get_indent() { - throw NotImplementedException("SamplePrintVisitor::visit(const LayerRoughness *) -> Error. Not implemented."); + std::string result; + result.resize(getLevel()*4, '.'); + result += " "; + return result; } +//! print default sample information +void SamplePrintVisitor::print_default(const ISample *sample) +{ + assert(sample); + std::cout << get_indent() << sample->getName() + << " " << (*sample->getParameterPool()) + << std::endl; +} diff --git a/dev-tools/python-bindings/MakePyCore.py b/dev-tools/python-bindings/MakePyCore.py index 0fb14ce4f53e4836a8a2803d7c91b8fb88b2c2aa..8c66bb61a66bbfcc29fa9ee70f897b0ce61b24aa 100644 --- a/dev-tools/python-bindings/MakePyCore.py +++ b/dev-tools/python-bindings/MakePyCore.py @@ -329,7 +329,7 @@ def MakePythonAPI(OutputTempDir): # default policies for what remained unchanged # ----------------- - #builder_utils.IncludePureVirtualMethods(mb, include_classes) + builder_utils.IncludePureVirtualMethods(mb, include_classes) builder_utils.DefaultReturnPolicy(mb) diff --git a/dev-tools/python-bindings/builder_utils.py b/dev-tools/python-bindings/builder_utils.py index 772644cc4c8855815c05bc7519a11127eb094894..c3d8c32bc89ac3c183d46136b7e6cdfe329603f5 100644 --- a/dev-tools/python-bindings/builder_utils.py +++ b/dev-tools/python-bindings/builder_utils.py @@ -50,10 +50,7 @@ def ExcludeMemberFunctionsArgPtr(mb): if has_pointers: #print "XXX",cl.name, fun.name fun.exclude(); - #query = declarations.virtuality_type_matcher_t( declarations.VIRTUALITY_TYPES.PURE_VIRTUAL ) - #fun = cl.member_functions( query, allow_empty=True ) - #for x in fun: - #print "ZZZ",x.name + #------------------------------------------------------------------------------ @@ -63,8 +60,10 @@ def IncludePureVirtualMethods(mb, include_classes): for cl in mb.classes(): itsOurClass = False for name in include_classes: - if name == cl.name or name == cl.alias: itsOurClass=True - if not itsOurClass: continue + if name == cl.name or name == cl.alias: + itsOurClass=True + if not itsOurClass: + continue query = declarations.virtuality_type_matcher_t( declarations.VIRTUALITY_TYPES.PURE_VIRTUAL ) fun = cl.member_functions( query, allow_empty=True ) for f in fun: