|
||||
File indexing completed on 2025-01-18 10:15:37
0001 //------------------------------------------------------------------------------ 0002 // Copyright (c) 2011-2014 by European Organization for Nuclear Research (CERN) 0003 // Author: Michal Simon <michal.simon@cern.ch> 0004 //------------------------------------------------------------------------------ 0005 // This file is part of the XRootD software suite. 0006 // 0007 // XRootD is free software: you can redistribute it and/or modify 0008 // it under the terms of the GNU Lesser General Public License as published by 0009 // the Free Software Foundation, either version 3 of the License, or 0010 // (at your option) any later version. 0011 // 0012 // XRootD is distributed in the hope that it will be useful, 0013 // but WITHOUT ANY WARRANTY; without even the implied warranty of 0014 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0015 // GNU General Public License for more details. 0016 // 0017 // You should have received a copy of the GNU Lesser General Public License 0018 // along with XRootD. If not, see <http://www.gnu.org/licenses/>. 0019 // 0020 // In applying this licence, CERN does not waive the privileges and immunities 0021 // granted to it by virtue of its status as an Intergovernmental Organization 0022 // or submit itself to any jurisdiction. 0023 //------------------------------------------------------------------------------ 0024 0025 #ifndef SRC_XRDEC_XRDECCONFIG_HH_ 0026 #define SRC_XRDEC_XRDECCONFIG_HH_ 0027 0028 #include "XrdEc/XrdEcRedundancyProvider.hh" 0029 #include "XrdEc/XrdEcObjCfg.hh" 0030 0031 #include <string> 0032 #include <unordered_map> 0033 0034 namespace XrdEc 0035 { 0036 //--------------------------------------------------------------------------- 0037 //! Global configuration for the EC module 0038 //--------------------------------------------------------------------------- 0039 class Config 0040 { 0041 public: 0042 0043 //----------------------------------------------------------------------- 0044 //! Singleton access 0045 //----------------------------------------------------------------------- 0046 static Config& Instance() 0047 { 0048 static Config config; 0049 return config; 0050 } 0051 0052 //----------------------------------------------------------------------- 0053 //! Get redundancy provider for given data object configuration 0054 //----------------------------------------------------------------------- 0055 RedundancyProvider& GetRedundancy( const ObjCfg &objcfg ) 0056 { 0057 std::string key; 0058 key += std::to_string( objcfg.nbchunks ); 0059 key += ':'; 0060 key += std::to_string( objcfg.nbparity ); 0061 key += '-'; 0062 key += std::to_string( uint8_t( objcfg.datasize ) ); 0063 0064 std::unique_lock<std::mutex> lck( mtx ); 0065 auto itr = redundancies.find( key ); 0066 if( itr == redundancies.end() ) 0067 { 0068 auto p = redundancies.emplace( std::piecewise_construct, 0069 std::forward_as_tuple(key), 0070 std::forward_as_tuple(objcfg) ); 0071 return p.first->second; 0072 } 0073 else 0074 return itr->second; 0075 } 0076 0077 bool enable_plugins; 0078 0079 private: 0080 0081 std::unordered_map<std::string, RedundancyProvider> redundancies; 0082 std::mutex mtx; 0083 0084 //----------------------------------------------------------------------- 0085 //! Constructor 0086 //----------------------------------------------------------------------- 0087 Config() : enable_plugins( true ) 0088 { 0089 } 0090 0091 Config( const Config& ) = delete; //< Copy constructor 0092 Config( Config&& ) = delete; //< Move constructor 0093 Config& operator=( const Config& ) = delete; //< Move assigment operator 0094 Config& operator=( Config&& ) = delete; //< Copy assigment operator 0095 }; 0096 } 0097 0098 0099 #endif /* SRC_XRDEC_XRDECCONFIG_HH_ */
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |