LibreCAD
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
customentitystorage.cpp
Go to the documentation of this file.
1 #include "customentitystorage.h"
2 
3 using namespace lc;
4 
5 //TODO: get a real ID
6 
7 CustomEntityStorage::CustomEntityStorage(const std::string& pluginName,
8  const std::string& entityName,
9  const geo::Coordinate& base,
10  const std::map<std::string, std::string> params) :
11  Block("LC_" + std::to_string(rand()), base),
12  _pluginName(pluginName),
13  _entityName(entityName),
14  _params(params) {
15 
16 }
17 
18 const std::string& CustomEntityStorage::pluginName() const {
19  return _pluginName;
20 }
21 
22 const std::string& CustomEntityStorage::entityName() const {
23  return _entityName;
24 }
25 
26 CustomEntityStorage_CSPtr CustomEntityStorage::setParam(const std::string& param, const std::string& value) const {
27  auto ces = std::make_shared<CustomEntityStorage>(_pluginName, _entityName, base(), _params);
28  ces->_params[param] = value;
29 
30  return ces;
31 }
32 
33 std::string CustomEntityStorage::param(const std::string& param) const {
34  try {
35  return _params.at(param);
36  }
37  catch (std::out_of_range& e) {
38  return "";
39  }
40 }
41 
42 const std::map<std::string, std::string>& CustomEntityStorage::params() const {
43  return _params;
44 }
const geo::Coordinate & base() const
Definition: block.cpp:16
CustomEntityStorage_CSPtr setParam(const std::string &param, const std::string &value) const
const std::string & entityName() const
std::string param(const std::string &param) const
const std::map< std::string, std::string > & params() const
std::map< std::string, std::string > _params
const std::string & pluginName() const
Definition: cadentity.h:12
CustomEntityStorage(const std::string &pluginName, const std::string &entityName, const geo::Coordinate &base, const std::map< std::string, std::string > params=std::map< std::string, std::string >())