Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:17:41

0001 
0002 // Copyright 2020, Jefferson Science Associates, LLC.
0003 // Subject to the terms in the LICENSE file found in the top-level directory.
0004 
0005 
0006 #ifndef JANA2_COMPONENTTESTS_H
0007 #define JANA2_COMPONENTTESTS_H
0008 
0009 
0010 #include <JANA/JEventSource.h>
0011 #include <JANA/JEventProcessor.h>
0012 
0013 struct SimpleSource : public JEventSource {
0014 
0015     std::atomic_int open_count {0};
0016     std::atomic_int close_count {0};
0017     std::atomic_int event_count {0};
0018 
0019     SimpleSource() {
0020         SetCallbackStyle(CallbackStyle::ExpertMode);
0021     }
0022 
0023     void Open() override {
0024         open_count += 1;
0025     }
0026 
0027     Result Emit(JEvent&) override {
0028         if (++event_count == 5) {
0029             return Result::FailureFinished;
0030         }
0031         return Result::Success;
0032     }
0033     void Close() override {
0034         close_count += 1;
0035     }
0036 };
0037 
0038 
0039 struct SimpleProcessor : public JEventProcessor {
0040 
0041     std::atomic_int init_count {0};
0042     std::atomic_int finish_count {0};
0043 
0044     SimpleProcessor() {
0045         SetCallbackStyle(CallbackStyle::ExpertMode);
0046     }
0047 
0048     void Init() override {
0049         init_count += 1;
0050     }
0051 
0052     void Process(const JEvent&) override {
0053     }
0054 
0055     void Finish() override {
0056         finish_count += 1;
0057     }
0058 };
0059 
0060 
0061 #endif //JANA2_COMPONENTTESTS_H