AGX Dynamics 2.38.0.2
Loading...
Searching...
No Matches
ObjectWrapper.h
Go to the documentation of this file.
1/*
2Copyright 2007-2024. Algoryx Simulation AB.
3
4All AGX source code, intellectual property, documentation, sample code,
5tutorials, scene files and technical white papers, are copyrighted, proprietary
6and confidential material of Algoryx Simulation AB. You may not download, read,
7store, distribute, publish, copy or otherwise disseminate, use or expose this
8material unless having a written signed agreement with Algoryx Simulation AB, or having been
9advised so by Algoryx Simulation AB for a time limited evaluation, or having purchased a
10valid commercial license from Algoryx Simulation AB.
11
12Algoryx Simulation AB disclaims all responsibilities for loss or damage caused
13from using this software, unless otherwise stated in written agreements with
14Algoryx Simulation AB.
15*/
16
17#ifndef AGX_OBJECTWRAPPER_H
18#define AGX_OBJECTWRAPPER_H
19
20#include <agx/Object.h>
21
22namespace agx
23{
24 template <typename T>
26 {
27 public:
28 ObjectWrapper(const agx::Name& name, const T& value = T());
29
30 T& get();
31 const T& get() const;
32
33 void set(const T& value);
34
35 protected:
36 virtual ~ObjectWrapper() {}
37
38 private:
39 T m_object;
40 };
41
42 #if 0
43 template <typename T>
44 class ObjectRefWrapper : public agx::Object
45 {
46 public:
47 ObjectRefWrapper(const agx::Name& name);
48
49 T *get();
50 const T *get() const;
51
52 void set(const T *value);
53
54 protected:
55 virtual ~ObjectRefWrapper() {}
56
57 private:
58 agx::ref_ptr<T> m_object;
59 };
60 #endif
61
62
63 /* Implementation */
64 template <typename T>
65 ObjectWrapper<T>::ObjectWrapper(const agx::Name& name, const T& value) : Object(name), m_object(value)
66 {
67 }
68
69 template <typename T>
70 AGX_FORCE_INLINE T& ObjectWrapper<T>::get() { return m_object; }
71
72 template <typename T>
73 AGX_FORCE_INLINE const T& ObjectWrapper<T>::get() const { return m_object; }
74
75 template <typename T>
76 AGX_FORCE_INLINE void ObjectWrapper<T>::set(const T& value) { m_object = value; }
77
78
80 #if 0
81 template <typename T>
82 ObjectWrapperRef<T>::ObjectWrapperRef(const agx::Name& name, T *object) : Object(name), m_object(object)
83 {
84 }
85
86 template <typename T>
87 AGX_FORCE_INLINE T *ObjectWrapperRef<T>::get() { return m_object; }
88
89 template <typename T>
90 AGX_FORCE_INLINE const T *ObjectWrapperRef<T>::get() const { return m_object; }
91
92 template <typename T>
93 AGX_FORCE_INLINE void ObjectWrapperRef<T>::set(T *object) { m_object = object; }
94 #endif
95}
96
97
98#endif /* AGX_OBJECTWRAPPER_H */
Representation of a name string.
Definition Name.h:33
void set(const T &value)
ObjectWrapper(const agx::Name &name, const T &value=T())
virtual ~ObjectWrapper()
agx::Object is a refcounted object with a name.
Definition Object.h:59
Smart pointer for handling referenced counted objects.
Definition ref_ptr.h:30
#define AGX_FORCE_INLINE
Definition macros.h:58
The agx namespace contains the dynamics/math part of the AGX Dynamics API.