]> git.mxchange.org Git - simgear.git/blob - simgear/nasal/cppbind/NasalObject.hxx
Canvas/Layout: tweak the way elements are exposed to Nasal.
[simgear.git] / simgear / nasal / cppbind / NasalObject.hxx
1 ///@file Object exposed to Nasal including a Nasal hash for data storage.
2 //
3 // Copyright (C) 2014  Thomas Geymayer <tomgey@gmail.com>
4 //
5 // This library is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU Library General Public
7 // License as published by the Free Software Foundation; either
8 // version 2 of the License, or (at your option) any later version.
9 //
10 // This library is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13 // Library General Public License for more details.
14 //
15 // You should have received a copy of the GNU Library General Public
16 // License along with this library; if not, write to the Free Software
17 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301, USA
18
19 #ifndef SG_NASAL_OBJECT_HXX_
20 #define SG_NASAL_OBJECT_HXX_
21
22 #include "NasalObjectHolder.hxx"
23 #include "Ghost.hxx"
24
25 namespace nasal
26 {
27   class Object:
28     public virtual SGVirtualWeakReferenced
29   {
30     public:
31
32       /**
33        *
34        * @param impl    Initial implementation hash (nasal part of
35        *                implementation)
36        */
37       Object(naRef impl = naNil());
38
39       void setImpl(naRef obj);
40       naRef getImpl() const;
41
42       bool _set(naContext c, const std::string& key, naRef val);
43       bool _get(naContext c, const std::string& key, naRef& out);
44
45       static void setupGhost();
46
47     protected:
48       ObjectHolder<> _nasal_impl;
49
50   };
51
52   typedef SGSharedPtr<Object> ObjectRef;
53   typedef SGWeakPtr<Object> ObjectWeakRef;
54   typedef Ghost<ObjectRef> NasalObject;
55
56 } // namespace nasal
57
58 #endif /* SG_NASAL_OBJECT_HXX_ */