Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/buildsystem/src/tinyxml/ticpprc.h @ 2214

Last change on this file since 2214 was 2138, checked in by rgrieder, 16 years ago

Added #define TIXML_USE_TICPP to the ticpp and tinyxml headers.
All the other changes (missing include, const, public & protected qualifiers, verbose errors) have been fixed by ticpp anyway.

  • Property svn:eol-style set to native
File size: 3.0 KB
Line 
1#define TIXML_USE_TICPP
2
3/*
4http://code.google.com/p/ticpp/
5Copyright (c) 2006 Ryan Pusztai, Ryan Mulder
6
7Permission is hereby granted, free of charge, to any person obtaining a copy of
8this software and associated documentation files (the "Software"), to deal in
9the Software without restriction, including without limitation the rights to
10use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
11the Software, and to permit persons to whom the Software is furnished to do so,
12subject to the following conditions:
13
14The above copyright notice and this permission notice shall be included in all
15copies or substantial portions of the Software.
16
17THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
19FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
20COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
21IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23*/
24
25#ifdef TIXML_USE_TICPP
26
27#ifndef TICPPRC_INCLUDED
28#define TICPPRC_INCLUDED
29
30#include <vector>
31
32// Forward declare ticpp::Node, so it can be made a friend of TiCppRC
33namespace ticpp
34{
35        class Base;
36}
37
38// Forward declare TiCppRCImp so TiCppRC can hold a pointer to it
39class TiCppRCImp;
40
41/**
42Base class for reference counting functionality
43*/
44class TiCppRC
45{
46        // Allow ticpp::Node to directly modify reference count
47        friend class ticpp::Base;
48
49private:
50
51        TiCppRCImp* m_tiRC; /**< Pointer to reference counter */
52
53public:
54
55        /**
56        Constructor
57        Spawns new reference counter with a pointer to this
58        */
59        TiCppRC();
60
61        /**
62        Destructor
63        Nullifies the pointer to this held by the reference counter
64        Decrements reference count
65        */
66        virtual ~TiCppRC();
67       
68        std::vector< ticpp::Base* > m_spawnedWrappers; /**< Remember all wrappers that we've created with 'new' - ( e.g. NodeFactory, FirstChildElement, etc. )*/
69
70        /**
71        Delete all container objects we've spawned with 'new'.
72        */
73        void DeleteSpawnedWrappers();
74};
75
76class TiCppRCImp
77{
78private:
79
80        int m_count;            /**< Holds reference count to me, and to the node I point to */
81
82        TiCppRC* m_tiCppRC;     /**< Holds pointer to an object inheriting TiCppRC */
83
84public:
85
86        /**
87        Initializes m_tiCppRC pointer, and set reference count to 1
88        */
89        TiCppRCImp( TiCppRC* tiCppRC );
90
91        /**
92        Allows the TiCppRC object to set the pointer to itself ( m_tiCppRc ) to NULL when the TiCppRC object is deleted
93        */
94        void Nullify();
95
96        /**
97        Increment Reference Count
98        */
99        void IncRef();
100
101        /**
102        Decrement Reference Count
103        */
104        void DecRef();
105
106        /**
107        Set Reference Count to 1 - dangerous! - Use only if you are sure of the consequences
108        */
109        void InitRef();
110
111        /**
112        Get internal pointer to the TiCppRC object - not reference counted, use at your own risk
113        */
114        TiCppRC* Get();
115
116        /**
117        Returns state of internal pointer - will be null if the object was deleted
118        */
119        bool IsNull();
120};
121
122#endif // TICPP_INCLUDED
123
124#endif // TIXML_USE_TICPP
Note: See TracBrowser for help on using the repository browser.