Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:01:39

0001 // Copyright 2024, Jefferson Science Associates, LLC.
0002 // Subject to the terms in the LICENSE file found in the top-level directory.
0003 // Created by Nathan Brei
0004 
0005 #pragma once
0006 #include <JANA/JService.h>
0007 #include <toml.hpp>
0008 #include <string>
0009 #include <map>
0010 #include <vector>
0011 #include <memory>
0012 
0013 namespace jana::services {
0014 
0015 
0016 class JWiringService : public JService {
0017 
0018 public:
0019     struct Wiring {
0020         std::string plugin_name;
0021         std::string type_name;
0022         std::string prefix;
0023         JEventLevel level = JEventLevel::None;
0024         std::vector<std::string> input_names;
0025         std::vector<JEventLevel> input_levels;
0026         std::vector<std::string> output_names;
0027         std::vector<JEventLevel> output_levels;
0028         std::map<std::string, std::string> configs;
0029     };
0030 
0031 private:
0032     Parameter<std::string> m_wirings_input_file {this, "jana:wiring_file", "wiring.toml", 
0033         "Path to TOML file containing wiring definitions"};
0034 
0035     Parameter<bool> m_strict_inheritance {this, "jana:wiring_strictness", true,
0036         "Allow multiple definitions inside wiring files"};
0037 
0038     std::vector<std::unique_ptr<Wiring>> m_wirings;
0039     std::map<std::string, Wiring*> m_wirings_from_prefix;
0040     std::map<std::pair<std::string,std::string>, std::vector<Wiring*>> m_wirings_from_type_and_plugin_names;
0041     std::vector<Wiring*> m_no_wirings;
0042 
0043 public:
0044     void Init() override;
0045 
0046     void AddWirings(std::vector<std::unique_ptr<Wiring>>& wirings, const std::string& source);
0047     void AddWirings(const toml::table& table, const std::string& source);
0048     void AddWirings(const std::string& filename);
0049 
0050     const Wiring*
0051     GetWiring(const std::string& prefix) const;
0052 
0053     const std::vector<Wiring*>&
0054     GetWirings(const std::string& plugin_name, const std::string& type_name) const;
0055 
0056     const std::vector<std::unique_ptr<Wiring>>& 
0057     GetWirings() const { return m_wirings; }
0058 
0059     static void Overlay(Wiring& above, const Wiring& below);
0060 };
0061 
0062 } // namespace jana::services
0063