1 // Wrapper class for Nasal hashes
3 // Copyright (C) 2012 Thomas Geymayer <tomgey@gmail.com>
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.
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.
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
19 #ifndef SG_NASAL_HASH_HXX_
20 #define SG_NASAL_HASH_HXX_
22 #include "to_nasal.hxx"
35 * Create a new Nasal Hash
37 * @param c Nasal context for creating the hash
42 * Initialize from an existing Nasal Hash
44 * @param hash Existing Nasal Hash
45 * @param c Nasal context for creating new Nasal objects
47 Hash(const naRef& hash, naContext c);
52 * @param name Member name
53 * @param ref Reference to Nasal object (naRef)
55 void set(const std::string& name, naRef ref);
58 * Set member to anything convertible using to_nasal
60 * @param name Member name
61 * @param val Value (has to be convertible with to_nasal)
64 void set(const std::string& name, const T& val)
66 set(name, to_nasal(_context, val));
70 * Create a new child hash (module)
72 * @param name Name of the new hash inside this hash
74 Hash createHash(const std::string& name);
77 * Set a new Nasal context. Eg. in FlightGear the context changes every
78 * frame, so if using the same Hash instance for multiple frames you have
79 * to update the context before using the Hash object.
81 void setContext(naContext context);
84 * Get Nasal representation of Hash
86 const naRef get_naRef() const;
97 #endif /* SG_NASAL_HASH_HXX_ */