Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/questsystem2/src/tinyxml/ticpprc.h @ 2385

Last change on this file since 2385 was 1505, checked in by rgrieder, 17 years ago

f* svn: It doesn't even inform you if you attempt to set a non existing property. It is svn:eol-style and not eol-style when using the command by the way…

  • Property svn:eol-style set to native
File size: 2.7 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
31// Forward declare ticpp::Node, so it can be made a friend of TiCppRC
32namespace ticpp
33{
34        class Base;
35}
36
37// Forward declare TiCppRCImp so TiCppRC can hold a pointer to it
38class TiCppRCImp;
39
40/**
41Base class for reference counting functionality
42*/
43class TiCppRC
44{
45        // Allow ticpp::Node to directly modify reference count
46        friend class ticpp::Base;
47
48private:
49
50        TiCppRCImp* m_tiRC; /**< Pointer to reference counter */
51
52public:
53
54        /**
55        Constructor
56        Spawns new reference counter with a pointer to this
57        */
58        TiCppRC();
59
60        /**
61        Destructor
62        Nullifies the pointer to this held by the reference counter
63        Decrements reference count
64        */
65        virtual ~TiCppRC();
66};
67
68class TiCppRCImp
69{
70private:
71
72        int m_count;            /**< Holds reference count to me, and to the node I point to */
73
74        TiCppRC* m_tiCppRC;     /**< Holds pointer to an object inheriting TiCppRC */
75
76public:
77
78        /**
79        Initializes m_tiCppRC pointer, and set reference count to 1
80        */
81        TiCppRCImp( TiCppRC* tiCppRC );
82
83        /**
84        Allows the TiCppRC object to set the pointer to itself ( m_tiCppRc ) to NULL when the TiCppRC object is deleted
85        */
86        void Nullify();
87
88        /**
89        Increment Reference Count
90        */
91        void IncRef();
92
93        /**
94        Decrement Reference Count
95        */
96        void DecRef();
97
98        /**
99        Set Reference Count to 1 - dangerous! - Use only if you are sure of the consequences
100        */
101        void InitRef();
102
103        /**
104        Get internal pointer to the TiCppRC object - not reference counted, use at your own risk
105        */
106        TiCppRC* Get();
107
108        /**
109        Returns state of internal pointer - will be null if the object was deleted
110        */
111        bool IsNull();
112};
113
114#endif // TICPP_INCLUDED
115
116#endif // TIXML_USE_TICPP
Note: See TracBrowser for help on using the repository browser.