diff --git a/Framework/Cascade/Cascade.h b/Framework/Cascade/Cascade.h index 50396b025c816a94f95466920ad542bf90f38e4f..b2aa17216a6b6c9bfaab96ee38569ba7b2b7cf19 100644 --- a/Framework/Cascade/Cascade.h +++ b/Framework/Cascade/Cascade.h @@ -62,7 +62,7 @@ namespace corsika::cascade { // DoCascadeEquations(); // } } - + void Step(Particle& particle) { [[maybe_unused]] double nextStep = fProcesseList.MinStepLength(particle); // corsika::utls::ignore(nextStep); @@ -80,7 +80,7 @@ namespace corsika::cascade { fProcesseList.DoDiscrete(particle, fStack); } } - + private: ProcessList& fProcesseList; Stack& fStack; diff --git a/Framework/Particles/ParticleProperties.cc b/Framework/Particles/ParticleProperties.cc index 1100b55a2689c1fb30b9997c6dfe6df985ed45a8..6c8230561f6d76b0bf44a8b68bbdc62e1dab4f0d 100644 --- a/Framework/Particles/ParticleProperties.cc +++ b/Framework/Particles/ParticleProperties.cc @@ -1,3 +1,14 @@ + +/** + * (c) Copyright 2018 CORSIKA Project, corsika-project@lists.kit.edu + * + * See file AUTHORS for a list of contributors. + * + * This software is distributed under the terms of the GNU General Public + * Licence version 3 (GPL Version 3). See file LICENSE for a full version of + * the license. + */ + #include <corsika/particles/ParticleProperties.h> namespace corsika::particles::io { diff --git a/Framework/ProcessSequence/BaseProcess.h b/Framework/ProcessSequence/BaseProcess.h new file mode 100644 index 0000000000000000000000000000000000000000..897497d83c82caee4dbc6c19f90996a5ee7f97fa --- /dev/null +++ b/Framework/ProcessSequence/BaseProcess.h @@ -0,0 +1,45 @@ + +/** + * (c) Copyright 2018 CORSIKA Project, corsika-project@lists.kit.edu + * + * See file AUTHORS for a list of contributors. + * + * This software is distributed under the terms of the GNU General Public + * Licence version 3 (GPL Version 3). See file LICENSE for a full version of + * the license. + */ + +#ifndef _include_corsika_baseprocess_h_ +#define _include_corsika_baseprocess_h_ + +#include <corsika/process/ProcessReturn.h> // for convenience + +namespace corsika::process { + + /** + \class BaseProcess + + The structural base type of a process object in a + ProcessSequence. Both, the ProcessSequence and all its elements + are of type BaseProcess<T> + + */ + + template <typename derived> + struct BaseProcess { + derived& GetRef() { return static_cast<derived&>(*this); } + const derived& GetRef() const { return static_cast<const derived&>(*this); } + }; + + template <typename T> + struct is_base { + static const bool value = false; + }; + template <typename T> + struct is_base<BaseProcess<T>> { + static const bool value = true; + }; + +} // namespace corsika::process + +#endif diff --git a/Framework/ProcessSequence/CMakeLists.txt b/Framework/ProcessSequence/CMakeLists.txt index 9852db42b1639b27470d66253de69d5a5e561ee6..c24567821d938b68fa27e9f2a7be29eec33bb295 100644 --- a/Framework/ProcessSequence/CMakeLists.txt +++ b/Framework/ProcessSequence/CMakeLists.txt @@ -10,6 +10,9 @@ set ( #header files of this library set ( CORSIKAprocesssequence_HEADERS + BaseProcess.h + ContinuousProcess.h + DiscreteProcess.h ProcessSequence.h ProcessReturn.h ) diff --git a/Framework/ProcessSequence/ContinuousProcess.h b/Framework/ProcessSequence/ContinuousProcess.h new file mode 100644 index 0000000000000000000000000000000000000000..c53365f1afcdfb64ac808580077dd0e284dcdbd2 --- /dev/null +++ b/Framework/ProcessSequence/ContinuousProcess.h @@ -0,0 +1,36 @@ + +/** + * (c) Copyright 2018 CORSIKA Project, corsika-project@lists.kit.edu + * + * See file AUTHORS for a list of contributors. + * + * This software is distributed under the terms of the GNU General Public + * Licence version 3 (GPL Version 3). See file LICENSE for a full version of + * the license. + */ + +#ifndef _include_corsika_continuousprocess_h_ +#define _include_corsika_continuousprocess_h_ + +#include <corsika/process/ProcessReturn.h> // for convenience + +namespace corsika::process { + + /** + \class ContinuousProcess + + The structural base type of a process object in a + ProcessSequence. Both, the ProcessSequence and all its elements + are of type ContinuousProcess<T> + + */ + + template <typename derived> + struct ContinuousProcess { + derived& GetRef() { return static_cast<derived&>(*this); } + const derived& GetRef() const { return static_cast<const derived&>(*this); } + }; + +} // namespace corsika::process + +#endif diff --git a/Framework/ProcessSequence/DiscreteProcess.h b/Framework/ProcessSequence/DiscreteProcess.h new file mode 100644 index 0000000000000000000000000000000000000000..83064f5d8767c93619f6742d50c56aeae0863700 --- /dev/null +++ b/Framework/ProcessSequence/DiscreteProcess.h @@ -0,0 +1,56 @@ + +/** + * (c) Copyright 2018 CORSIKA Project, corsika-project@lists.kit.edu + * + * See file AUTHORS for a list of contributors. + * + * This software is distributed under the terms of the GNU General Public + * Licence version 3 (GPL Version 3). See file LICENSE for a full version of + * the license. + */ + +#ifndef _include_corsika_discreteprocess_h_ +#define _include_corsika_discreteprocess_h_ + +#include <corsika/process/ProcessReturn.h> // for convenience + +#include <iostream> // debug + +namespace corsika::process { + + /** + \class DiscreteProcess + + The structural base type of a process object in a + ProcessSequence. Both, the ProcessSequence and all its elements + are of type DiscreteProcess<T> + + */ + + template <typename derived> + struct DiscreteProcess { + + // DiscreteProcess() { + // static_assert(mustProvide<derived>::mustProvide, ""); + //} + + derived& GetRef() { return static_cast<derived&>(*this); } + const derived& GetRef() const { return static_cast<const derived&>(*this); } + + // here starts the interface part + // -> enforce derived to implement DoDiscrete... + template <typename Particle, typename Stack> + inline EProcessReturn DoDiscrete(Particle&, Stack&) const; // {} + + // private: + template <typename D, typename T, typename S> + inline EProcessReturn DoContinuous(D& d, T&, S&) const { + std::cout << "yeah" << std::endl; + return EProcessReturn::eOk; + } // find out how to make this FINAL + // void DoContinuous; + }; + +} // namespace corsika::process + +#endif diff --git a/Framework/ProcessSequence/ProcessSequence.h b/Framework/ProcessSequence/ProcessSequence.h index 4b2fc83c28ad0e1ec978c24814e5a4285a00aa40..a6d51e4b5821df2ba8b82a0c19a1a98b86476493 100644 --- a/Framework/ProcessSequence/ProcessSequence.h +++ b/Framework/ProcessSequence/ProcessSequence.h @@ -12,28 +12,112 @@ #ifndef _include_ProcessSequence_h_ #define _include_ProcessSequence_h_ +#include <corsika/process/BaseProcess.h> +#include <corsika/process/ContinuousProcess.h> +#include <corsika/process/DiscreteProcess.h> #include <corsika/process/ProcessReturn.h> -#include <cmath> -#include <iostream> -#include <typeinfo> +//#include <type_traits> // still needed ? namespace corsika::process { - /** - \class BaseProcess - - The structural base type of a process object in a - ProcessSequence. Both, the ProcessSequence and all its elements - are of type BaseProcess<T> - - */ - - template <typename derived> - struct BaseProcess { - derived& GetRef() { return static_cast<derived&>(*this); } - const derived& GetRef() const { return static_cast<const derived&>(*this); } - }; + /* namespace detail { */ + + /* /\* template<typename TT1, typename TT2, typename Type = void> *\/ */ + /* /\* struct CallHello { *\/ */ + /* /\* static void Call(const TT1&, const TT2&) { *\/ */ + /* /\* std::cout << "normal" << std::endl; *\/ */ + /* /\* } *\/ */ + /* /\* }; *\/ */ + + /* /\* template<typename TT1, typename TT2> *\/ */ + /* /\* struct CallHello<TT1, TT2, typename + * std::enable_if<std::is_base_of<ContinuousProcess<TT2>, TT2>::value>::type> *\/ */ + /* /\* { *\/ */ + /* /\* static void Call(const TT1&, const TT2&) { *\/ */ + /* /\* std::cout << "special" << std::endl; *\/ */ + /* /\* } *\/ */ + /* /\* }; *\/ */ + + /* template<typename T1, typename T2, typename Particle, typename Trajectory, typename + * Stack> //, typename Type = void> */ + /* struct DoContinuous { */ + /* static EProcessReturn Call(const T1& A, const T2& B, Particle& p, Trajectory& t, + * Stack& s) { */ + /* EProcessReturn ret = EProcessReturn::eOk; */ + /* if constexpr (!std::is_base_of<DiscreteProcess<T1>, T1>::value) { */ + /* A.DoContinuous(p, t, s); */ + /* } */ + /* if constexpr (!std::is_base_of<DiscreteProcess<T2>, T2>::value) { */ + /* B.DoContinuous(p, t, s); */ + /* } */ + /* return ret; */ + /* } */ + /* }; */ + + /* /\* */ + /* template<typename T1, typename T2, typename Particle, typename Trajectory, typename + * Stack> */ + /* struct DoContinuous<T1,T2,Particle,Trajectory,Stack, typename + * std::enable_if<std::is_base_of<DiscreteProcess<T1>, T1>::value>::type> { */ + /* static EProcessReturn Call(const T1& A, const T2& B, Particle& p, Trajectory& t, + * Stack& s) { */ + /* EProcessReturn ret = EProcessReturn::eOk; */ + /* A.DoContinuous(p, t, s); */ + /* B.DoContinuous(p, t, s); */ + /* return ret; */ + /* } */ + /* }; */ + + /* template<typename T1, typename T2, typename Particle, typename Trajectory, + * typename Stack> */ + /* struct DoContinuous<T1,T2,Particle,Trajectory,Stack, typename + * std::enable_if<std::is_base_of<DiscreteProcess<T2>, T2>::value>::type> { */ + /* static EProcessReturn Call(const T1& A, const T2&, Particle& p, Trajectory& t, + * Stack& s) { */ + /* EProcessReturn ret = EProcessReturn::eOk; */ + /* A.DoContinuous(p, t, s); */ + /* B.DoContinuous(p, t, s); */ + /* return ret; */ + /* } */ + /* }; */ + /* *\/ */ + + /* template<typename T1, typename T2, typename Particle, typename Stack>//, typename + * Type = void> */ + /* struct DoDiscrete { */ + /* static EProcessReturn Call(const T1& A, const T2& B, Particle& p, Stack& s) { */ + /* if constexpr (!std::is_base_of<ContinuousProcess<T1>, T1>::value) { */ + /* A.DoDiscrete(p, s); */ + /* } */ + /* if constexpr (!std::is_base_of<ContinuousProcess<T2>, T2>::value) { */ + /* B.DoDiscrete(p, s); */ + /* } */ + /* return EProcessReturn::eOk; */ + /* } */ + /* }; */ + /* /\* */ + /* template<typename T1, typename T2, typename Particle, typename Stack> */ + /* struct DoDiscrete<T1,T2,Particle,Stack, typename + * std::enable_if<std::is_base_of<ContinuousProcess<T1>, T1>::value>::type> { */ + /* static EProcessReturn Call(const T1&, const T2& B, Particle& p, Stack& s) { */ + /* // A.DoDiscrete(p, s); */ + /* B.DoDiscrete(p, s); */ + /* return EProcessReturn::eOk; */ + /* } */ + /* }; */ + + /* template<typename T1, typename T2, typename Particle, typename Stack> */ + /* struct DoDiscrete<T1,T2,Particle,Stack, typename + * std::enable_if<std::is_base_of<ContinuousProcess<T2>, T2>::value>::type> { */ + /* static EProcessReturn Call(const T1& A, const T2&, Particle& p, Stack& s) { */ + /* A.DoDiscrete(p, s); */ + /* //B.DoDiscrete(p, s); */ + /* return EProcessReturn::eOk; */ + /* } */ + /* }; */ + /* *\/ */ + /* } // end namespace detail */ /** \class ProcessSequence @@ -56,19 +140,27 @@ namespace corsika::process { : A(in_A) , B(in_B) {} + // example for a trait-based call: + // void Hello() const { detail::CallHello<T1,T2>::Call(A, B); } + template <typename Particle, typename Trajectory, typename Stack> inline EProcessReturn DoContinuous(Particle& p, Trajectory& t, Stack& s) const { EProcessReturn ret = EProcessReturn::eOk; - /*ret |=*/A.DoContinuous(p, t, s); - /*ret |=*/B.DoContinuous(p, t, s); + if constexpr (!std::is_base_of<DiscreteProcess<T1>, T1>::value) { + A.DoContinuous(p, t, s); + } + if constexpr (!std::is_base_of<DiscreteProcess<T2>, T2>::value) { + B.DoContinuous(p, t, s); + } return ret; - } // add trajectory + } template <typename D> inline double MinStepLength(D& d) const { return std::min(A.MinStepLength(d), B.MinStepLength(d)); } + /* template <typename Particle, typename Trajectory> inline Trajectory Transport(Particle& p, double& length) const { A.Transport(p, length); // todo: maybe check (?) if there is more than one Transport @@ -76,11 +168,17 @@ namespace corsika::process { return B.Transport( p, length); // need to do this also to decide which Trajectory to return!!!! } + */ template <typename Particle, typename Stack> - void DoDiscrete(Particle& p, Stack& s) const { - A.DoDiscrete(p, s); - B.DoDiscrete(p, s); + inline EProcessReturn DoDiscrete(Particle& p, Stack& s) const { + if constexpr (!std::is_base_of<ContinuousProcess<T1>, T1>::value) { + A.DoDiscrete(p, s); + } + if constexpr (!std::is_base_of<ContinuousProcess<T2>, T2>::value) { + B.DoDiscrete(p, s); + } + return EProcessReturn::eOk; } /// TODO the const_cast is not nice, think about the constness here @@ -90,13 +188,27 @@ namespace corsika::process { } }; - /// the + operator that assembles more BaseProcess objects into a ProcessSequence - template <typename T1, typename T2> - inline const ProcessSequence<T1, T2> operator+(const BaseProcess<T1>& A, - const BaseProcess<T2>& B) { - return ProcessSequence<T1, T2>(A.GetRef(), B.GetRef()); + /// the +operator assembles many BaseProcess, ContinuousProcess, and + /// DiscreteProcess objects into a ProcessSequence, all combinatoris + /// must be allowed, this is why we define a macro to define all + /// combinations here: + +#define OPSEQ(C1, C2) \ + template <typename T1, typename T2> \ + inline const ProcessSequence<T1, T2> operator+(const C1<T1>& A, const C2<T2>& B) { \ + return ProcessSequence<T1, T2>(A.GetRef(), B.GetRef()); \ } + OPSEQ(BaseProcess, BaseProcess) + OPSEQ(BaseProcess, DiscreteProcess) + OPSEQ(BaseProcess, ContinuousProcess) + OPSEQ(ContinuousProcess, BaseProcess) + OPSEQ(ContinuousProcess, DiscreteProcess) + OPSEQ(ContinuousProcess, ContinuousProcess) + OPSEQ(DiscreteProcess, BaseProcess) + OPSEQ(DiscreteProcess, DiscreteProcess) + OPSEQ(DiscreteProcess, ContinuousProcess) + /* template <typename T1> struct depth_lhs diff --git a/Framework/ProcessSequence/ProcessSignature.h b/Framework/ProcessSequence/ProcessSignature.h new file mode 100644 index 0000000000000000000000000000000000000000..cb0081df416b19057f995065545f92d4f083f8a0 --- /dev/null +++ b/Framework/ProcessSequence/ProcessSignature.h @@ -0,0 +1,32 @@ + +/** + * (c) Copyright 2018 CORSIKA Project, corsika-project@lists.kit.edu + * + * See file AUTHORS for a list of contributors. + * + * This software is distributed under the terms of the GNU General Public + * Licence version 3 (GPL Version 3). See file LICENSE for a full version of + * the license. + */ + +#ifndef _include_process_processsignature_h_ +#define _include_process_processsignature_h_ + +#define FORCE_SIGNATURE(nameTrait, nameMethod, signatureMethod) \ + template <typename U> \ + class nameTrait { \ + private: \ + template <typename T, T> \ + struct helper; \ + template <typename T> \ + static std::uint8_t check(helper<signatureMethod, &nameMethod>*); \ + template <typename T> \ + static std::uint16_t check(...); \ + \ + public: \ + static constexpr bool value = sizeof(check<U>(0)) == sizeof(std::uint8_t); \ + } + +// FORCE_SIGNATURE(thisMustBeDefined, T::thisMustBeDefined, int(*)(void)); + +#endif diff --git a/Framework/ProcessSequence/testProcessSequence.cc b/Framework/ProcessSequence/testProcessSequence.cc index b144230eb5fa81a11caf0c98dd28d9ca8b043a05..2d4b46b15f11a8d9b396bf24e0073bdc2cdbb147 100644 --- a/Framework/ProcessSequence/testProcessSequence.cc +++ b/Framework/ProcessSequence/testProcessSequence.cc @@ -22,43 +22,94 @@ using namespace std; using namespace corsika::process; -class Process1 : public BaseProcess<Process1> { +class ContinuousProcess1 : public ContinuousProcess<ContinuousProcess1> { +public: + ContinuousProcess1() {} + void Init() { cout << "ContinuousProcess1::Init" << endl; } + template <typename D, typename T, typename S> + inline EProcessReturn DoContinuous(D& d, T&, S&) const { + cout << "ContinuousProcess1::DoContinuous" << endl; + for (int i = 0; i < 10; ++i) d.p[i] += 0.933; + return EProcessReturn::eOk; + } + + template <typename Particle, typename Stack> + inline EProcessReturn DoDiscrete(Particle&, Stack&) const { + cout << "ContinuousProcess1::DoDiscrete" << endl; + return EProcessReturn::eOk; + } +}; + +class ContinuousProcess2 : public ContinuousProcess<ContinuousProcess2> { +public: + ContinuousProcess2() {} + void Init() { cout << "ContinuousProcess2::Init" << endl; } + template <typename D, typename T, typename S> + inline EProcessReturn DoContinuous(D& d, T&, S&) const { + cout << "ContinuousProcess2::DoContinuous" << endl; + for (int i = 0; i < 20; ++i) d.p[i] += 0.933; + return EProcessReturn::eOk; + } + + template <typename Particle, typename Stack> + inline EProcessReturn DoDiscrete(Particle&, Stack&) const { + cout << "ContinuousProcess2::DoDiscrete" << endl; + return EProcessReturn::eOk; + } +}; + +class Process1 : public DiscreteProcess<Process1> { public: Process1() {} - void Init() {} // cout << "Process1::Init" << endl; } + void Init() { cout << "Process1::Init" << endl; } template <typename D, typename T, typename S> inline EProcessReturn DoContinuous(D& d, T&, S&) const { for (int i = 0; i < 10; ++i) d.p[i] += 1 + i; return EProcessReturn::eOk; } + template <typename Particle, typename Stack> + inline EProcessReturn DoDiscrete(Particle&, Stack&) const { + cout << "Process1::DoDiscrete" << endl; + return EProcessReturn::eOk; + } }; -class Process2 : public BaseProcess<Process2> { +class Process2 : public DiscreteProcess<Process2> { public: Process2() {} - void Init() {} // cout << "Process2::Init" << endl; } + void Init() { cout << "Process2::Init" << endl; } template <typename D, typename T, typename S> inline EProcessReturn DoContinuous(D& d, T&, S&) const { for (int i = 0; i < 10; ++i) d.p[i] *= 0.7; return EProcessReturn::eOk; } + template <typename Particle, typename Stack> + inline EProcessReturn DoDiscrete(Particle&, Stack&) const { + cout << "Process2::DoDiscrete" << endl; + return EProcessReturn::eOk; + } }; -class Process3 : public BaseProcess<Process3> { +class Process3 : public DiscreteProcess<Process3> { public: Process3() {} - void Init() {} // cout << "Process3::Init" << endl; } + void Init() { cout << "Process3::Init" << endl; } template <typename D, typename T, typename S> inline EProcessReturn DoContinuous(D& d, T&, S&) const { for (int i = 0; i < 10; ++i) d.p[i] += 0.933; return EProcessReturn::eOk; } + template <typename Particle, typename Stack> + inline EProcessReturn DoDiscrete(Particle&, Stack&) const { + cout << "Process3::DoDiscrete" << endl; + return EProcessReturn::eOk; + } }; class Process4 : public BaseProcess<Process4> { public: Process4() {} - void Init() {} // cout << "Process4::Init" << endl; } + void Init() { cout << "Process4::Init" << endl; } template <typename D, typename T, typename S> inline EProcessReturn DoContinuous(D& d, T&, S&) const { for (int i = 0; i < 10; ++i) d.p[i] /= 1.2; @@ -85,17 +136,30 @@ TEST_CASE("Cascade", "[Cascade]") { const auto sequence = m1 + m2 + m3 + m4; + ContinuousProcess1 cp1; + ContinuousProcess2 cp2; + + const auto sequence2 = cp1 + m2 + m3 + cp2; + DummyData p; DummyTrajectory t; DummyStack s; + cout << "-->init" << endl; + sequence2.Init(); + cout << "-->docont" << endl; + sequence2.DoContinuous(p, t, s); + cout << "-->dodisc" << endl; + sequence2.DoDiscrete(p, s); + cout << "-->done" << endl; + sequence.Init(); const int n = 100; - INFO("Running loop with n=" << n); + cout << "Running loop with n=" << n << endl; for (int i = 0; i < n; ++i) { sequence.DoContinuous(p, t, s); } - for (int i = 0; i < 10; i++) { INFO("data[" << i << "]=" << p.p[i]); } + for (int i = 0; i < 10; i++) { cout << "data[" << i << "]=" << p.p[i] << endl; } } SECTION("sectionThree") {} diff --git a/Processes/StackInspector/StackInspector.cc b/Processes/StackInspector/StackInspector.cc index 3455294e4e6eb6db54f96d0170ad88144a711a99..5717953f93296478c8692e3903e0c0b91b5f53e5 100644 --- a/Processes/StackInspector/StackInspector.cc +++ b/Processes/StackInspector/StackInspector.cc @@ -1,3 +1,14 @@ + +/** + * (c) Copyright 2018 CORSIKA Project, corsika-project@lists.kit.edu + * + * See file AUTHORS for a list of contributors. + * + * This software is distributed under the terms of the GNU General Public + * Licence version 3 (GPL Version 3). See file LICENSE for a full version of + * the license. + */ + #include <corsika/process/stack_inspector/StackInspector.h> #include <corsika/units/PhysicalUnits.h> diff --git a/Processes/StackInspector/StackInspector.h b/Processes/StackInspector/StackInspector.h index 3127177692bdf2cc3dd75694600962252af8f39d..d608eda37c74df42a7ca058ddec06f0d91f3c114 100644 --- a/Processes/StackInspector/StackInspector.h +++ b/Processes/StackInspector/StackInspector.h @@ -1,7 +1,18 @@ + +/** + * (c) Copyright 2018 CORSIKA Project, corsika-project@lists.kit.edu + * + * See file AUTHORS for a list of contributors. + * + * This software is distributed under the terms of the GNU General Public + * Licence version 3 (GPL Version 3). See file LICENSE for a full version of + * the license. + */ + #ifndef _Physics_StackInspector_StackInspector_h_ #define _Physics_StackInspector_StackInspector_h_ -#include <corsika/process/ProcessSequence.h> +#include <corsika/process/ContinuousProcess.h> namespace corsika::process { @@ -9,7 +20,7 @@ namespace corsika::process { template <typename Stack, typename Trajectory> class StackInspector - : public corsika::process::BaseProcess<StackInspector<Stack, Trajectory>> { + : public corsika::process::ContinuousProcess<StackInspector<Stack, Trajectory>> { typedef typename Stack::ParticleType Particle; diff --git a/Processes/StackInspector/testStackInspector.cc b/Processes/StackInspector/testStackInspector.cc index 311c732cec4b3cbdb8bcb4d4886b37df0e940696..c098b025b678427f1e244fc8052d0dd889f11d08 100644 --- a/Processes/StackInspector/testStackInspector.cc +++ b/Processes/StackInspector/testStackInspector.cc @@ -1,3 +1,14 @@ + +/** + * (c) Copyright 2018 CORSIKA Project, corsika-project@lists.kit.edu + * + * See file AUTHORS for a list of contributors. + * + * This software is distributed under the terms of the GNU General Public + * Licence version 3 (GPL Version 3). See file LICENSE for a full version of + * the license. + */ + #define CATCH_CONFIG_MAIN // This tells Catch to provide a main() - only do this in one // cpp file #include <catch2/catch.hpp> diff --git a/Setup/SetupEnvironment.h b/Setup/SetupEnvironment.h index ef97fecbab9b393e445a7d1d95502e45a548a1aa..1beb2748052770fc25b84991fdf3e651744c3dc8 100644 --- a/Setup/SetupEnvironment.h +++ b/Setup/SetupEnvironment.h @@ -1,3 +1,14 @@ + +/** + * (c) Copyright 2018 CORSIKA Project, corsika-project@lists.kit.edu + * + * See file AUTHORS for a list of contributors. + * + * This software is distributed under the terms of the GNU General Public + * Licence version 3 (GPL Version 3). See file LICENSE for a full version of + * the license. + */ + #ifndef _include_corsika_setup_environment_h_ #define _include_corsika_setup_environment_h_ diff --git a/Setup/SetupLogger.h b/Setup/SetupLogger.h index 4383a15705cdf1d083508767965e8eb33edbee0d..2760bc7623fd244f38647d03e956e06ba39e84cd 100644 --- a/Setup/SetupLogger.h +++ b/Setup/SetupLogger.h @@ -1,3 +1,14 @@ + +/** + * (c) Copyright 2018 CORSIKA Project, corsika-project@lists.kit.edu + * + * See file AUTHORS for a list of contributors. + * + * This software is distributed under the terms of the GNU General Public + * Licence version 3 (GPL Version 3). See file LICENSE for a full version of + * the license. + */ + #ifndef _include_corsika_setup_logger_h_ #define _include_corsika_setup_logger_h_ diff --git a/Setup/SetupStack.h b/Setup/SetupStack.h index ec57cf0836d6e547e5124b2564761a85323ec686..053d485f9e2352112f8c3db9dddfeba6bee775bf 100644 --- a/Setup/SetupStack.h +++ b/Setup/SetupStack.h @@ -1,3 +1,14 @@ + +/** + * (c) Copyright 2018 CORSIKA Project, corsika-project@lists.kit.edu + * + * See file AUTHORS for a list of contributors. + * + * This software is distributed under the terms of the GNU General Public + * Licence version 3 (GPL Version 3). See file LICENSE for a full version of + * the license. + */ + #ifndef _corsika_setup_setupstack_h_ #define _corsika_setup_setupstack_h_ diff --git a/Setup/SetupTrajectory.h b/Setup/SetupTrajectory.h index dd903e79cc78c1bc149b11cbaf1139d49020c323..ab95732be88bcc44489c78b7cf6343b4f4ee9dd7 100644 --- a/Setup/SetupTrajectory.h +++ b/Setup/SetupTrajectory.h @@ -1,3 +1,14 @@ + +/** + * (c) Copyright 2018 CORSIKA Project, corsika-project@lists.kit.edu + * + * See file AUTHORS for a list of contributors. + * + * This software is distributed under the terms of the GNU General Public + * Licence version 3 (GPL Version 3). See file LICENSE for a full version of + * the license. + */ + #ifndef _corsika_setup_setuptrajectory_h_ #define _corsika_setup_setuptrajectory_h_ diff --git a/do-copyright.py b/do-copyright.py index dcbd9d0593f260e69bd1effc84560a8e1307dbfa..c771a570f5908067ea89c4ef2e8c934ac9c79b61 100755 --- a/do-copyright.py +++ b/do-copyright.py @@ -42,13 +42,28 @@ def checkNote(filename): endNote = iLine iLine += 1 - #if startNote>=0 and endNote>=0 and isCopyright: - #print filename - #for iLine in range(startNote, endNote+1): - # print lines[iLine] - - os.rename(filename, filename+".bak") + # now check if copyright notice is already there and identical... + isSame = False + if startNote>=0 and endNote>=0 and isCopyright: + isSame = True + noteLines = text.split('\n') + for iLine in range(len(noteLines)-2): + if startNote+iLine >= len(lines): + isSame = False + break + if noteLines[iLine+1].strip(" \n") != lines[startNote+iLine].strip(" \n"): + isSame = False + print "not same: " + filename + " new=\'" + noteLines[iLine+1] + "\' vs old=\'" + lines[startNote+iLine].rstrip('\n') + "\'" + break + + # check if notice is the same + if isSame: + return + # add (new) copyright notice here: + + os.rename(filename, filename+".bak") + with open(filename, "w") as file: file.write(text)