diff options
author | Andreas Stöckel <astoecke@techfak.uni-bielefeld.de> | 2014-12-21 15:28:30 +0100 |
---|---|---|
committer | Andreas Stöckel <andreas@somweyr.de> | 2014-12-21 15:28:30 +0100 |
commit | da3b35e77c1e22b46264df4c1b2a48f867d1e15e (patch) | |
tree | d483940d49f2d5ba7fac86187174cc7d70714f9d /src/core/common | |
parent | 54d66cfa220128ae6c7cd05aa5db3354e459105b (diff) |
changed RttiTypes from class to namespace
Diffstat (limited to 'src/core/common')
-rw-r--r-- | src/core/common/Function.cpp | 2 | ||||
-rw-r--r-- | src/core/common/Function.hpp | 33 | ||||
-rw-r--r-- | src/core/common/Rtti.hpp | 22 |
3 files changed, 31 insertions, 26 deletions
diff --git a/src/core/common/Function.cpp b/src/core/common/Function.cpp index d4b8ccc..ab049c6 100644 --- a/src/core/common/Function.cpp +++ b/src/core/common/Function.cpp @@ -20,5 +20,7 @@ namespace ousia { +const Rtti<Function> RttiTypes::Function("function"); + } diff --git a/src/core/common/Function.hpp b/src/core/common/Function.hpp index 0274603..e0d87dd 100644 --- a/src/core/common/Function.hpp +++ b/src/core/common/Function.hpp @@ -29,23 +29,25 @@ #define _OUSIA_FUNCTION_HPP_ #include <cassert> -#include <memory> #include <core/managed/Managed.hpp> +#include "Rtti.hpp" #include "Variant.hpp" namespace ousia { /** - * The AbstractFunction interface defines all the methods needed to represent - * a reference at a generic function object. Function objects can be called - * using the call function in which an array of Variant is supplied to the - * function and a Variant is returned to the caller. + * The Function interface defines all the methods needed to represent a + * generic function. Function objects can be called using the "call" function in + * which an array of Variant is supplied to the function and a Variant is + * returned to the caller. */ -class AbstractFunction : public Managed { -public: +class Function : public Managed { +protected: + using Managed::Managed; +public: /** * Abstract function which is meant to call the underlying function (be it * a host or a script function) with the given arguments. @@ -65,7 +67,7 @@ public: * @tparam T is the type of the method that should be called. */ template <class T> -class Method : public AbstractFunction { +class Method : public Function { public: /** * Type of the Callback function that is being called by the "call" @@ -85,6 +87,8 @@ private: const Callback method; public: + using Function::Function; + /** * Constructor of the Method class. * @@ -93,14 +97,6 @@ public: Method(Callback method) : method(method){}; /** - * Creates a copy of this Method object. - */ - std::unique_ptr<AbstractFunction> clone() const override - { - return std::unique_ptr<AbstractFunction>{new Method<T>(method)}; - } - - /** * Calls the underlying method. * * @param args is a vector containing all arguments that shouild be passed @@ -120,6 +116,11 @@ public: return method(args, tRef); } }; + +namespace RttiTypes { + extern const Rtti<Function> Function; +} + } #endif /* _OUSIA_FUNCTION_HPP_ */ diff --git a/src/core/common/Rtti.hpp b/src/core/common/Rtti.hpp index b91bd35..b46a8fa 100644 --- a/src/core/common/Rtti.hpp +++ b/src/core/common/Rtti.hpp @@ -49,11 +49,13 @@ * \code{.hpp} * // Only needed if the type needs to be accessed * // from other compilation units! - * extern const Rtti<MyType> MyType_Rtti; + * namespace RttiTypes { + * extern const Rtti<MyType> MyType; + * } * \endcode * In the source file: * \code{.cpp} - * const Rtti<MyType> MyType_Rtti{"MyType", {&MyOtherType_Rtti}, [...]}; + * const Rtti<MyType> RttiTypes::MyType{"MyType", {&RttiTypes::MyOtherType}, [...]}; * \endcode * * @author Andreas Stöckel (astoecke@techfak.uni-bielefeld.de) @@ -215,37 +217,37 @@ inline const RttiBase &typeOf(const T &obj) * constants are used to e.g. define the type of function arguments while * allowing for both primitive variant types and more complex variant types. */ -struct RttiTypes { +namespace RttiTypes { /** * Type of no particular color. */ - static const RttiBase None; + extern const RttiBase None; /** * Constant representing a variant int type. */ - static const RttiBase Int; + extern const RttiBase Int; /** * Constant representing a variant double type. */ - static const RttiBase Double; + extern const RttiBase Double; /** * Constant representing a variant string type. */ - static const RttiBase String; + extern const RttiBase String; /** * Constant representing a variant array type. */ - static const RttiBase Array; + extern const RttiBase Array; /** * Constant representing a variant map type. */ - static const RttiBase Map; -}; + extern const RttiBase Map; +} } |