IODA Bundle
CodecFactory.cc
Go to the documentation of this file.
1 /*
2  * (C) Copyright 1996-2012 ECMWF.
3  *
4  * This software is licensed under the terms of the Apache Licence Version 2.0
5  * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
6  * In applying this licence, ECMWF does not waive the privileges and immunities
7  * granted to it by virtue of its status as an intergovernmental organisation nor
8  * does it submit to any jurisdiction.
9  */
10 
11 #include "odc/core/CodecFactory.h"
12 
13 #include "eckit/exception/Exceptions.h"
14 
15 
16 namespace odc {
17 namespace core {
18 
19 //----------------------------------------------------------------------------------------------------------------------
20 
22 
24 
26  static CodecFactory theInstance;
27  return theInstance;
28 }
29 
30 void CodecFactory::enregister(const std::string& name, CodecBuilderBase& builder) {
31 
32  std::lock_guard<std::mutex> lock(m_);
33 
34  ASSERT(builders_.find(name) == builders_.end());
35  builders_.emplace(name, builder);
36 }
37 
38 void CodecFactory::deregister(const std::string& name, CodecBuilderBase& builder) {
39 
40  std::lock_guard<std::mutex> lock(m_);
41 
42  auto it = builders_.find(name);
43  ASSERT(it != builders_.end());
44  builders_.erase(it);
45 }
46 
48  name_(name) {
50 }
51 
54 }
55 
56 //----------------------------------------------------------------------------------------------------------------------
57 
58 } // namespace core
59 } // namespace odc
CodecBuilderBase(const std::string &name)
Definition: CodecFactory.cc:47
void deregister(const std::string &name, CodecBuilderBase &builder)
Definition: CodecFactory.cc:38
std::map< std::string, std::reference_wrapper< CodecBuilderBase > > builders_
Definition: CodecFactory.h:63
static CodecFactory & instance()
Definition: CodecFactory.cc:25
void enregister(const std::string &name, CodecBuilderBase &builder)
Definition: CodecFactory.cc:30
Definition: ColumnInfo.h:23