Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-09-07 04:36:22

0001 #ifndef Subsystem_Package_dummy_helpers_h
0002 #define Subsystem_Package_dummy_helpers_h
0003 // -*- C++ -*-
0004 //
0005 // Package:     Subsystem/Package
0006 // Class  :     dummy_helpers
0007 //
0008 /**\class dummy_helpers dummy_helpers.h "dummy_helpers.h"
0009 
0010  Description: [one line class summary]
0011 
0012  Usage:
0013     <usage>
0014 
0015 */
0016 //
0017 // Original Author:  Chris Jones
0018 //         Created:  Sat, 03 Aug 2013 21:42:38 GMT
0019 //
0020 
0021 // system include files
0022 #include <memory>
0023 #include <vector>
0024 #include <mutex>
0025 // user include files
0026 
0027 // forward declarations
0028 
0029 namespace edm {
0030   namespace stream {
0031     namespace impl {
0032       struct dummy_ptr {
0033         void* get() { return nullptr; }
0034         void reset(void*) {}
0035         void* release() { return nullptr; }
0036       };
0037 
0038       struct dummy_vec {
0039         void resize(size_t) {}
0040         dummy_ptr operator[](unsigned int) { return dummy_ptr(); }
0041       };
0042 
0043       struct dummy_mutex {
0044         void lock() {}
0045         void unlock() {}
0046       };
0047 
0048       template <typename T>
0049       struct choose_unique_ptr {
0050         typedef std::unique_ptr<T> type;
0051       };
0052       template <>
0053       struct choose_unique_ptr<void> {
0054         typedef dummy_ptr type;
0055       };
0056 
0057       template <>
0058       struct choose_unique_ptr<void const> {
0059         typedef dummy_ptr type;
0060       };
0061 
0062       template <typename T>
0063       struct choose_shared_vec {
0064         typedef std::vector<std::shared_ptr<T>> type;
0065       };
0066       template <>
0067       struct choose_shared_vec<void> {
0068         typedef dummy_vec type;
0069       };
0070       template <>
0071       struct choose_shared_vec<void const> {
0072         typedef dummy_vec type;
0073       };
0074       template <typename T>
0075       struct choose_mutex {
0076         using type = std::mutex;
0077       };
0078       template <>
0079       struct choose_mutex<void> {
0080         using type = dummy_mutex;
0081       };
0082     }  // namespace impl
0083   }  // namespace stream
0084 }  // namespace edm
0085 
0086 #endif