summaryrefslogtreecommitdiff
path: root/include/gras
diff options
context:
space:
mode:
authorJosh Blum2013-03-21 20:11:08 -0700
committerJosh Blum2013-03-21 20:11:08 -0700
commit8c3b96b2b7c9bfda6b19fd96a4305ded8d52a164 (patch)
treeb808ee29d71270af7eedb50faa226f5eabb7ac18 /include/gras
parent5485d42efba261c8879d1208c31d9cd5d18c303d (diff)
downloadsandhi-8c3b96b2b7c9bfda6b19fd96a4305ded8d52a164.tar.gz
sandhi-8c3b96b2b7c9bfda6b19fd96a4305ded8d52a164.tar.bz2
sandhi-8c3b96b2b7c9bfda6b19fd96a4305ded8d52a164.zip
gras: move element details into header
Diffstat (limited to 'include/gras')
-rw-r--r--include/gras/CMakeLists.txt1
-rw-r--r--include/gras/detail/element.hpp27
-rw-r--r--include/gras/element.hpp21
3 files changed, 36 insertions, 13 deletions
diff --git a/include/gras/CMakeLists.txt b/include/gras/CMakeLists.txt
index 12e1bb1..0ea4f2d 100644
--- a/include/gras/CMakeLists.txt
+++ b/include/gras/CMakeLists.txt
@@ -30,6 +30,7 @@ install(FILES
detail/block.hpp
detail/chrono.hpp
+ detail/element.hpp
detail/sbuffer.hpp
detail/work_buffer.hpp
diff --git a/include/gras/detail/element.hpp b/include/gras/detail/element.hpp
new file mode 100644
index 0000000..35033e1
--- /dev/null
+++ b/include/gras/detail/element.hpp
@@ -0,0 +1,27 @@
+// Copyright (C) by Josh Blum. See LICENSE.txt for licensing information.
+
+#ifndef INCLUDED_GRAS_DETAIL_ELEMENT_HPP
+#define INCLUDED_GRAS_DETAIL_ELEMENT_HPP
+
+namespace gras
+{
+ template <typename T>
+ inline Element::Element(const boost::shared_ptr<T> &elem)
+ {
+ *this = elem->shared_to_element();
+ }
+
+ //! Convert a shared ptr of a derived class to an Element
+ inline Element &Element::shared_to_element(void)
+ {
+ try
+ {
+ this->weak_self = this->shared_from_this();
+ }
+ catch(...){}
+ return *this;
+ }
+
+} //namespace gras
+
+#endif /*INCLUDED_GRAS_DETAIL_ELEMENT_HPP*/
diff --git a/include/gras/element.hpp b/include/gras/element.hpp
index 2b236ce..3211ac3 100644
--- a/include/gras/element.hpp
+++ b/include/gras/element.hpp
@@ -28,6 +28,10 @@ struct GRAS_API Element : ElementBase, boost::enable_shared_from_this<Element>
//! Creates a new element given the name
Element(const std::string &name);
+ /*******************************************************************
+ * identification interface
+ ******************************************************************/
+
//! An integer ID that is unique across the process
long unique_id(void) const;
@@ -45,21 +49,10 @@ struct GRAS_API Element : ElementBase, boost::enable_shared_from_this<Element>
* Good for that factory function/shared ptr paradigm.
*/
template <typename T>
- inline Element(const boost::shared_ptr<T> &elem)
- {
- *this = elem->shared_to_element();
- }
+ inline Element(const boost::shared_ptr<T> &elem);
//! Convert a shared ptr of a derived class to an Element
- inline Element &shared_to_element(void)
- {
- try
- {
- this->weak_self = this->shared_from_this();
- }
- catch(...){}
- return *this;
- }
+ inline Element &shared_to_element(void);
//! for internal use only
boost::weak_ptr<Element> weak_self;
@@ -68,6 +61,8 @@ struct GRAS_API Element : ElementBase, boost::enable_shared_from_this<Element>
} //namespace gras
+#include <gras/detail/element.hpp>
+
#ifdef _MSC_VER
#pragma warning(pop)
#endif //_MSC_VER