Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-15 09:18:31

0001 #ifndef PODIO_ARROWTYPEREGISTRY_H
0002 #define PODIO_ARROWTYPEREGISTRY_H
0003 
0004 #include <memory>
0005 #include <string>
0006 #include <unordered_map>
0007 
0008 // Forward declaration of arrow::DataType to avoid including Arrow headers globally
0009 namespace arrow {
0010 class DataType;
0011 }
0012 
0013 namespace podio {
0014 
0015 /**
0016  * @brief Global singleton registry mapping PODIO type name strings to their
0017  * corresponding Apache Arrow DataTypes.
0018  *
0019  * Registration happens lazily on the first call to getType, when the necessary
0020  * datamodel-specific Arrow converter libraries (e.g., libedm4hepArrow.so,
0021  * libTestDataModelArrow.so) are loaded. It is expected that this happens before
0022  * worker threads query the registry. Once populated, the registry is read-only
0023  * and can be safely accessed from multiple threads concurrently.
0024  */
0025 class ArrowTypeRegistry {
0026 public:
0027   ArrowTypeRegistry(const ArrowTypeRegistry&) = delete;
0028   ArrowTypeRegistry& operator=(const ArrowTypeRegistry&) = delete;
0029   ArrowTypeRegistry(ArrowTypeRegistry&&) = delete;
0030   ArrowTypeRegistry& operator=(ArrowTypeRegistry&&) = delete;
0031   ~ArrowTypeRegistry() = default;
0032 
0033   /// Get the mutable singleton instance for registration
0034   static ArrowTypeRegistry& mutInstance();
0035 
0036   /// Get the read-only singleton instance
0037   static ArrowTypeRegistry const& instance();
0038 
0039   /**
0040    * @brief Register an Arrow DataType for a specific type name.
0041    */
0042   void registerType(const std::string& typeName, std::shared_ptr<arrow::DataType> type);
0043 
0044   /**
0045    * @brief Retrieve the Arrow DataType registered for a specific type name.
0046    * @return The registered DataType, or nullptr if not registered.
0047    */
0048   std::shared_ptr<arrow::DataType> getType(const std::string& typeName) const;
0049 
0050 private:
0051   ArrowTypeRegistry();
0052 
0053   std::unordered_map<std::string, std::shared_ptr<arrow::DataType>> m_registry;
0054 };
0055 
0056 } // namespace podio
0057 
0058 #endif // PODIO_ARROWTYPEREGISTRY_H