IAP GITLAB

Skip to content
Snippets Groups Projects
Commit 1f76c211 authored by Ralf Ulrich's avatar Ralf Ulrich
Browse files

Merge branch 'different_types_of_processes' into 'master'

Different types of processes

See merge request AirShowerPhysics/corsika!12
parents a22541b0 7dd04aa4
No related branches found
No related tags found
No related merge requests found
Showing
with 498 additions and 47 deletions
...@@ -62,7 +62,7 @@ namespace corsika::cascade { ...@@ -62,7 +62,7 @@ namespace corsika::cascade {
// DoCascadeEquations(); // // DoCascadeEquations(); //
} }
} }
void Step(Particle& particle) { void Step(Particle& particle) {
[[maybe_unused]] double nextStep = fProcesseList.MinStepLength(particle); [[maybe_unused]] double nextStep = fProcesseList.MinStepLength(particle);
// corsika::utls::ignore(nextStep); // corsika::utls::ignore(nextStep);
...@@ -80,7 +80,7 @@ namespace corsika::cascade { ...@@ -80,7 +80,7 @@ namespace corsika::cascade {
fProcesseList.DoDiscrete(particle, fStack); fProcesseList.DoDiscrete(particle, fStack);
} }
} }
private: private:
ProcessList& fProcesseList; ProcessList& fProcesseList;
Stack& fStack; Stack& fStack;
......
/**
* (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> #include <corsika/particles/ParticleProperties.h>
namespace corsika::particles::io { namespace corsika::particles::io {
......
/**
* (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
...@@ -10,6 +10,9 @@ set ( ...@@ -10,6 +10,9 @@ set (
#header files of this library #header files of this library
set ( set (
CORSIKAprocesssequence_HEADERS CORSIKAprocesssequence_HEADERS
BaseProcess.h
ContinuousProcess.h
DiscreteProcess.h
ProcessSequence.h ProcessSequence.h
ProcessReturn.h ProcessReturn.h
) )
......
/**
* (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
/**
* (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
...@@ -12,28 +12,112 @@ ...@@ -12,28 +12,112 @@
#ifndef _include_ProcessSequence_h_ #ifndef _include_ProcessSequence_h_
#define _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 <corsika/process/ProcessReturn.h>
#include <cmath> //#include <type_traits> // still needed ?
#include <iostream>
#include <typeinfo>
namespace corsika::process { namespace corsika::process {
/** /* namespace detail { */
\class BaseProcess
/* /\* template<typename TT1, typename TT2, typename Type = void> *\/ */
The structural base type of a process object in a /* /\* struct CallHello { *\/ */
ProcessSequence. Both, the ProcessSequence and all its elements /* /\* static void Call(const TT1&, const TT2&) { *\/ */
are of type BaseProcess<T> /* /\* std::cout << "normal" << std::endl; *\/ */
/* /\* } *\/ */
*/ /* /\* }; *\/ */
template <typename derived> /* /\* template<typename TT1, typename TT2> *\/ */
struct BaseProcess { /* /\* struct CallHello<TT1, TT2, typename
derived& GetRef() { return static_cast<derived&>(*this); } * std::enable_if<std::is_base_of<ContinuousProcess<TT2>, TT2>::value>::type> *\/ */
const derived& GetRef() const { return static_cast<const derived&>(*this); } /* /\* { *\/ */
}; /* /\* 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 \class ProcessSequence
...@@ -56,19 +140,27 @@ namespace corsika::process { ...@@ -56,19 +140,27 @@ namespace corsika::process {
: A(in_A) : A(in_A)
, B(in_B) {} , 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> template <typename Particle, typename Trajectory, typename Stack>
inline EProcessReturn DoContinuous(Particle& p, Trajectory& t, Stack& s) const { inline EProcessReturn DoContinuous(Particle& p, Trajectory& t, Stack& s) const {
EProcessReturn ret = EProcessReturn::eOk; EProcessReturn ret = EProcessReturn::eOk;
/*ret |=*/A.DoContinuous(p, t, s); if constexpr (!std::is_base_of<DiscreteProcess<T1>, T1>::value) {
/*ret |=*/B.DoContinuous(p, t, s); A.DoContinuous(p, t, s);
}
if constexpr (!std::is_base_of<DiscreteProcess<T2>, T2>::value) {
B.DoContinuous(p, t, s);
}
return ret; return ret;
} // add trajectory }
template <typename D> template <typename D>
inline double MinStepLength(D& d) const { inline double MinStepLength(D& d) const {
return std::min(A.MinStepLength(d), B.MinStepLength(d)); return std::min(A.MinStepLength(d), B.MinStepLength(d));
} }
/*
template <typename Particle, typename Trajectory> template <typename Particle, typename Trajectory>
inline Trajectory Transport(Particle& p, double& length) const { inline Trajectory Transport(Particle& p, double& length) const {
A.Transport(p, length); // todo: maybe check (?) if there is more than one Transport A.Transport(p, length); // todo: maybe check (?) if there is more than one Transport
...@@ -76,11 +168,17 @@ namespace corsika::process { ...@@ -76,11 +168,17 @@ namespace corsika::process {
return B.Transport( return B.Transport(
p, length); // need to do this also to decide which Trajectory to return!!!! p, length); // need to do this also to decide which Trajectory to return!!!!
} }
*/
template <typename Particle, typename Stack> template <typename Particle, typename Stack>
void DoDiscrete(Particle& p, Stack& s) const { inline EProcessReturn DoDiscrete(Particle& p, Stack& s) const {
A.DoDiscrete(p, s); if constexpr (!std::is_base_of<ContinuousProcess<T1>, T1>::value) {
B.DoDiscrete(p, s); 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 /// TODO the const_cast is not nice, think about the constness here
...@@ -90,13 +188,27 @@ namespace corsika::process { ...@@ -90,13 +188,27 @@ namespace corsika::process {
} }
}; };
/// the + operator that assembles more BaseProcess objects into a ProcessSequence /// the +operator assembles many BaseProcess, ContinuousProcess, and
template <typename T1, typename T2> /// DiscreteProcess objects into a ProcessSequence, all combinatoris
inline const ProcessSequence<T1, T2> operator+(const BaseProcess<T1>& A, /// must be allowed, this is why we define a macro to define all
const BaseProcess<T2>& B) { /// combinations here:
return ProcessSequence<T1, T2>(A.GetRef(), B.GetRef());
#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> template <typename T1>
struct depth_lhs struct depth_lhs
......
/**
* (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
...@@ -22,43 +22,94 @@ ...@@ -22,43 +22,94 @@
using namespace std; using namespace std;
using namespace corsika::process; 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: public:
Process1() {} Process1() {}
void Init() {} // cout << "Process1::Init" << endl; } void Init() { cout << "Process1::Init" << endl; }
template <typename D, typename T, typename S> template <typename D, typename T, typename S>
inline EProcessReturn DoContinuous(D& d, T&, S&) const { inline EProcessReturn DoContinuous(D& d, T&, S&) const {
for (int i = 0; i < 10; ++i) d.p[i] += 1 + i; for (int i = 0; i < 10; ++i) d.p[i] += 1 + i;
return EProcessReturn::eOk; 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: public:
Process2() {} Process2() {}
void Init() {} // cout << "Process2::Init" << endl; } void Init() { cout << "Process2::Init" << endl; }
template <typename D, typename T, typename S> template <typename D, typename T, typename S>
inline EProcessReturn DoContinuous(D& d, T&, S&) const { inline EProcessReturn DoContinuous(D& d, T&, S&) const {
for (int i = 0; i < 10; ++i) d.p[i] *= 0.7; for (int i = 0; i < 10; ++i) d.p[i] *= 0.7;
return EProcessReturn::eOk; 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: public:
Process3() {} Process3() {}
void Init() {} // cout << "Process3::Init" << endl; } void Init() { cout << "Process3::Init" << endl; }
template <typename D, typename T, typename S> template <typename D, typename T, typename S>
inline EProcessReturn DoContinuous(D& d, T&, S&) const { inline EProcessReturn DoContinuous(D& d, T&, S&) const {
for (int i = 0; i < 10; ++i) d.p[i] += 0.933; for (int i = 0; i < 10; ++i) d.p[i] += 0.933;
return EProcessReturn::eOk; 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> { class Process4 : public BaseProcess<Process4> {
public: public:
Process4() {} Process4() {}
void Init() {} // cout << "Process4::Init" << endl; } void Init() { cout << "Process4::Init" << endl; }
template <typename D, typename T, typename S> template <typename D, typename T, typename S>
inline EProcessReturn DoContinuous(D& d, T&, S&) const { inline EProcessReturn DoContinuous(D& d, T&, S&) const {
for (int i = 0; i < 10; ++i) d.p[i] /= 1.2; for (int i = 0; i < 10; ++i) d.p[i] /= 1.2;
...@@ -85,17 +136,30 @@ TEST_CASE("Cascade", "[Cascade]") { ...@@ -85,17 +136,30 @@ TEST_CASE("Cascade", "[Cascade]") {
const auto sequence = m1 + m2 + m3 + m4; const auto sequence = m1 + m2 + m3 + m4;
ContinuousProcess1 cp1;
ContinuousProcess2 cp2;
const auto sequence2 = cp1 + m2 + m3 + cp2;
DummyData p; DummyData p;
DummyTrajectory t; DummyTrajectory t;
DummyStack s; 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(); sequence.Init();
const int n = 100; 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 < 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") {} SECTION("sectionThree") {}
......
/**
* (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/process/stack_inspector/StackInspector.h>
#include <corsika/units/PhysicalUnits.h> #include <corsika/units/PhysicalUnits.h>
......
/**
* (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_ #ifndef _Physics_StackInspector_StackInspector_h_
#define _Physics_StackInspector_StackInspector_h_ #define _Physics_StackInspector_StackInspector_h_
#include <corsika/process/ProcessSequence.h> #include <corsika/process/ContinuousProcess.h>
namespace corsika::process { namespace corsika::process {
...@@ -9,7 +20,7 @@ namespace corsika::process { ...@@ -9,7 +20,7 @@ namespace corsika::process {
template <typename Stack, typename Trajectory> template <typename Stack, typename Trajectory>
class StackInspector class StackInspector
: public corsika::process::BaseProcess<StackInspector<Stack, Trajectory>> { : public corsika::process::ContinuousProcess<StackInspector<Stack, Trajectory>> {
typedef typename Stack::ParticleType Particle; typedef typename Stack::ParticleType Particle;
......
/**
* (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 #define CATCH_CONFIG_MAIN // This tells Catch to provide a main() - only do this in one
// cpp file // cpp file
#include <catch2/catch.hpp> #include <catch2/catch.hpp>
......
/**
* (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_ #ifndef _include_corsika_setup_environment_h_
#define _include_corsika_setup_environment_h_ #define _include_corsika_setup_environment_h_
......
/**
* (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_ #ifndef _include_corsika_setup_logger_h_
#define _include_corsika_setup_logger_h_ #define _include_corsika_setup_logger_h_
......
/**
* (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_ #ifndef _corsika_setup_setupstack_h_
#define _corsika_setup_setupstack_h_ #define _corsika_setup_setupstack_h_
......
/**
* (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_ #ifndef _corsika_setup_setuptrajectory_h_
#define _corsika_setup_setuptrajectory_h_ #define _corsika_setup_setuptrajectory_h_
......
...@@ -42,13 +42,28 @@ def checkNote(filename): ...@@ -42,13 +42,28 @@ def checkNote(filename):
endNote = iLine endNote = iLine
iLine += 1 iLine += 1
#if startNote>=0 and endNote>=0 and isCopyright: # now check if copyright notice is already there and identical...
#print filename isSame = False
#for iLine in range(startNote, endNote+1): if startNote>=0 and endNote>=0 and isCopyright:
# print lines[iLine] isSame = True
noteLines = text.split('\n')
os.rename(filename, filename+".bak") 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: with open(filename, "w") as file:
file.write(text) file.write(text)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment