Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/FICN/src/util/tinyxml/ticpprc.h @ 744

Last change on this file since 744 was 742, checked in by landauf, 17 years ago

moved all files from misc and the tinyxml folder into the new util folder

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