icedb  version 0.5.1
Snow particle scattering database API
options.hpp
Go to the documentation of this file.
1 #pragma once
2 #include "../icedb/defs.h"
3 #include <memory>
4 #include <string>
5 #include <iostream>
6 #include "../icedb/optionsForwards.hpp"
7 
8 namespace icedb {
9  namespace registry {
10  class options : public std::enable_shared_from_this<options>
11  {
12  protected:
13  options();
14  std::shared_ptr<options_inner> p;
15  public:
16  virtual ~options();
17  static std::shared_ptr<options> generate();
18  void enumVals(std::ostream &out) const;
19  bool hasVal(const std::string &key) const;
21  template <class T> T getVal(const std::string &key) const;
23  template <class T> T getVal(const std::string &key, const T& defaultval) const;
25  template <class T> options_ptr setVal(const std::string &key, const T &value);
27  template <class T> options_ptr add(const std::string &key, const T &value);
28 
29  // Some convenient definitions
30  inline void filename(const std::string& val) { setVal<std::string>("filename", val); }
31  inline std::string filename() const { return getVal<std::string>("filename", ""); }
32  inline void extension(const std::string& val) { setVal<std::string>("extension", val); }
33  inline std::string extension() const { return getVal<std::string>("extension", ""); }
34  inline void filetype(const std::string &val) { setVal<std::string>("filetype", val); }
35  inline std::string filetype() const { return getVal<std::string>("filetype", ""); }
36  inline void exportType(const std::string &val) { setVal<std::string>("exportType", val); }
37  inline std::string exportType() const { return getVal<std::string>("exportType", ""); }
38  };
39  }
40 }
void enumVals(std::ostream &out) const
Definition: options.cpp:22
void exportType(const std::string &val)
Definition: options.hpp:36
std::string exportType() const
Definition: options.hpp:37
options_ptr setVal(const std::string &key, const T &value)
Adds or replaces an option.
Definition: options.cpp:53
bool hasVal(const std::string &key) const
Definition: options.cpp:35
static std::shared_ptr< options > generate()
Definition: options.cpp:18
T getVal(const std::string &key) const
Retrieves an option. Throws if nonexistant.
Definition: options.cpp:39
std::string filetype() const
Definition: options.hpp:35
std::string extension() const
Definition: options.hpp:33
options_ptr add(const std::string &key, const T &value)
Adds an option. Throws if the same name already exists.
Definition: options.cpp:59
std::shared_ptr< options_inner > p
Definition: options.hpp:14
void extension(const std::string &val)
Definition: options.hpp:32
std::shared_ptr< options > options_ptr
std::string filename() const
Definition: options.hpp:31
void filetype(const std::string &val)
Definition: options.hpp:34
void filename(const std::string &val)
Definition: options.hpp:30