summaryrefslogtreecommitdiff
path: root/include/gras/detail/block.hpp
diff options
context:
space:
mode:
authorJosh Blum2013-03-17 11:17:15 -0700
committerJosh Blum2013-03-17 11:17:15 -0700
commitb142e0e75f8ab4e7b2bb70c3fc71b61fd5f71651 (patch)
tree95fee7787912a90cce81cd3a8ce902068eff481e /include/gras/detail/block.hpp
parentcebd974738fea792f70bca8ab0bb1d73e2116d81 (diff)
downloadsandhi-b142e0e75f8ab4e7b2bb70c3fc71b61fd5f71651.tar.gz
sandhi-b142e0e75f8ab4e7b2bb70c3fc71b61fd5f71651.tar.bz2
sandhi-b142e0e75f8ab4e7b2bb70c3fc71b61fd5f71651.zip
gras: work on C++ API for properties interface
Diffstat (limited to 'include/gras/detail/block.hpp')
-rw-r--r--include/gras/detail/block.hpp35
1 files changed, 35 insertions, 0 deletions
diff --git a/include/gras/detail/block.hpp b/include/gras/detail/block.hpp
new file mode 100644
index 0000000..483b2bf
--- /dev/null
+++ b/include/gras/detail/block.hpp
@@ -0,0 +1,35 @@
+// Copyright (C) by Josh Blum. See LICENSE.txt for licensing information.
+
+#ifndef INCLUDED_GRAS_DETAIL_BLOCK_HPP
+#define INCLUDED_GRAS_DETAIL_BLOCK_HPP
+
+namespace gras
+{
+
+template <typename ClassType, typename ValueType>
+GRAS_FORCE_INLINE void Block::register_property(
+ const std::string &key,
+ ValueType(ClassType::*get)(void),
+ void(ClassType::*set)(const ValueType &)
+)
+{
+ boost::shared_ptr<PropertyRegistry> pr;
+ pr.reset(new PropertyRegistryImpl<ClassType, ValueType>(this, get, set));
+ this->property_interface_register(key, pr);
+}
+
+template <typename ValueType>
+GRAS_FORCE_INLINE void Block::set_property(const std::string &key, const ValueType &value)
+{
+ return this->property_interface_set(key, PMC_M(value));
+}
+
+template <typename ValueType>
+GRAS_FORCE_INLINE ValueType Block::get_property(const std::string &key)
+{
+ return this->property_interface_get(key).as<ValueType>();
+}
+
+} //namespace gras
+
+#endif /*INCLUDED_GRAS_DETAIL_BLOCK_HPP*/