IODA Bundle
DataHandleFactory.h
Go to the documentation of this file.
1 /*
2  * (C) Copyright 1996-2016 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 /// @author Piotr Kuchta, May 2015
11 
12 #ifndef eckit_utils_DataHandleFactory_H
13 #define eckit_utils_DataHandleFactory_H
14 
15 #include <string>
16 #include <map>
17 
18 #include "eckit/filesystem/PathName.h"
19 
20 namespace eckit {
21  class DataHandle;
22  class MultiHandle;
23  class Length;
24 }
25 
26 namespace odc {
27 
29 public: // Types
30  typedef std::map<std::string, DataHandleFactory*> Storage;
31 
32 public:
33  virtual ~DataHandleFactory();
34 
35  static eckit::DataHandle* openForRead(const std::string&);
36  static eckit::DataHandle* openForWrite(const std::string&, const eckit::Length& = eckit::Length(0));
37 
38  static void buildMultiHandle(eckit::MultiHandle&, const std::vector<std::string>&);
39  static void buildMultiHandle(eckit::MultiHandle&, const std::string&);
40 
41 protected:
42  DataHandleFactory(const std::string&);
43 
44  static std::pair<std::string,std::string> splitPrefix(const std::string&);
45 
46  static eckit::DataHandle* makeHandle(const std::string&, const std::string&);
47 
48  virtual eckit::DataHandle* makeHandle(const std::string&) const = 0;
49  std::string prefix() const;
50 
51 private:
53  static Storage& factories();
54  static void registerFactories();
55 
56  std::string prefix_;
57 };
58 
59 } // namespace odc
60 
61 #endif
std::string prefix() const
static eckit::DataHandle * makeHandle(const std::string &, const std::string &)
static eckit::DataHandle * openForRead(const std::string &)
virtual eckit::DataHandle * makeHandle(const std::string &) const =0
static void buildMultiHandle(eckit::MultiHandle &, const std::vector< std::string > &)
std::map< std::string, DataHandleFactory * > Storage
static std::pair< std::string, std::string > splitPrefix(const std::string &)
static Storage & factories()
static eckit::DataHandle * openForWrite(const std::string &, const eckit::Length &=eckit::Length(0))
Definition: ColumnInfo.h:23