| 1 | //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ |
|---|
| 2 | // Zen Core Framework |
|---|
| 3 | // |
|---|
| 4 | // Copyright (C) 2001 - 2009 Tony Richards |
|---|
| 5 | // Copyright (C) 2008 - 2009 Matthew Alan Gray |
|---|
| 6 | // |
|---|
| 7 | // This software is provided 'as-is', without any express or implied |
|---|
| 8 | // warranty. In no event will the authors be held liable for any damages |
|---|
| 9 | // arising from the use of this software. |
|---|
| 10 | // |
|---|
| 11 | // Permission is granted to anyone to use this software for any purpose, |
|---|
| 12 | // including commercial applications, and to alter it and redistribute it |
|---|
| 13 | // freely, subject to the following restrictions: |
|---|
| 14 | // |
|---|
| 15 | // 1. The origin of this software must not be misrepresented; you must not |
|---|
| 16 | // claim that you wrote the original software. If you use this software |
|---|
| 17 | // in a product, an acknowledgment in the product documentation would be |
|---|
| 18 | // appreciated but is not required. |
|---|
| 19 | // 2. Altered source versions must be plainly marked as such, and must not be |
|---|
| 20 | // misrepresented as being the original software. |
|---|
| 21 | // 3. This notice may not be removed or altered from any source distribution. |
|---|
| 22 | // |
|---|
| 23 | // Tony Richards trichards@indiezen.com |
|---|
| 24 | // Matthew Alan Gray mgray@indiezen.org |
|---|
| 25 | //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ |
|---|
| 26 | #ifndef ZEN_SCRIPTING_I_OBJECT_HEAP_HPP_INCLUDED |
|---|
| 27 | #define ZEN_SCRIPTING_I_OBJECT_HEAP_HPP_INCLUDED |
|---|
| 28 | |
|---|
| 29 | #include "Configuration.hpp" |
|---|
| 30 | |
|---|
| 31 | #include <Zen/Core/Memory/managed_ptr.hpp> |
|---|
| 32 | #include <Zen/Core/Memory/managed_weak_ptr.hpp> |
|---|
| 33 | #include <Zen/Core/Event/Event.hpp> |
|---|
| 34 | |
|---|
| 35 | #include <string> |
|---|
| 36 | |
|---|
| 37 | //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ |
|---|
| 38 | namespace Zen { |
|---|
| 39 | namespace Scripting { |
|---|
| 40 | //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ |
|---|
| 41 | |
|---|
| 42 | class I_ObjectReference; |
|---|
| 43 | |
|---|
| 44 | class SCRIPTING_DLL_LINK I_ObjectHeap |
|---|
| 45 | { |
|---|
| 46 | /// @name Types |
|---|
| 47 | /// @{ |
|---|
| 48 | public: |
|---|
| 49 | typedef Zen::Memory::managed_ptr<I_ObjectHeap> pObjectHeap_type; |
|---|
| 50 | typedef Zen::Memory::managed_weak_ptr<I_ObjectHeap> wpObjectHeap_type; |
|---|
| 51 | typedef Zen::Event::Event<wpObjectHeap_type> objectHeapEvent_type; |
|---|
| 52 | |
|---|
| 53 | typedef Zen::Memory::managed_ptr<I_ObjectReference> pObjectReference_type; |
|---|
| 54 | /// @} |
|---|
| 55 | |
|---|
| 56 | /// @name I_ObjectHeap interface |
|---|
| 57 | /// @{ |
|---|
| 58 | public: |
|---|
| 59 | /// Create a new object based on the object reference. |
|---|
| 60 | /// This really doesn't do anything except maintain the |
|---|
| 61 | /// reference count of the C++ wrapped object. |
|---|
| 62 | virtual void createObject(pObjectReference_type _pObject) = 0; |
|---|
| 63 | |
|---|
| 64 | /// Get the global reference object from the heap that is the same |
|---|
| 65 | /// as the reference passed as a parameter. |
|---|
| 66 | virtual pObjectReference_type getGlobalReference(I_ObjectReference& _object) = 0; |
|---|
| 67 | /// @} |
|---|
| 68 | |
|---|
| 69 | /// @name Events |
|---|
| 70 | /// @{ |
|---|
| 71 | public: |
|---|
| 72 | objectHeapEvent_type onDestroyEvent; |
|---|
| 73 | /// @} |
|---|
| 74 | |
|---|
| 75 | /// @name 'Structors |
|---|
| 76 | /// @{ |
|---|
| 77 | protected: |
|---|
| 78 | I_ObjectHeap(); |
|---|
| 79 | virtual ~I_ObjectHeap(); |
|---|
| 80 | /// @} |
|---|
| 81 | |
|---|
| 82 | }; // interface I_ObjectHeap |
|---|
| 83 | |
|---|
| 84 | //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ |
|---|
| 85 | } // namespace Scripting |
|---|
| 86 | namespace Memory { |
|---|
| 87 | // I_ObjectHeap is managed by I_ScriptEngine |
|---|
| 88 | template<> |
|---|
| 89 | struct is_managed_by_factory<Scripting::I_ObjectHeap> : public boost::true_type{}; |
|---|
| 90 | } // namespace Memory |
|---|
| 91 | } // namespace Zen |
|---|
| 92 | //-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~ |
|---|
| 93 | |
|---|
| 94 | #endif // ZEN_SCRIPTING_I_OBJECT_HEAP_HPP_INCLUDED |
|---|