2 fegdk: FE Game Development Kit
3 Copyright (C) 2001-2008 Alexey "waker" Yakovenko
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
17 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 waker@users.sourceforge.net
24 #include "f_baseobject.h"
25 #include "f_helpers.h"
31 int baseObject::mLastId
= 0;
32 std::map
< int, baseObject
* > *baseObject::mpObjects
= NULL
;
43 leakManager::leakManager ()
47 leakManager::~leakManager ()
49 if (NULL
== baseObject::mpObjects
)
52 std::map
< int, baseObject
* >::iterator it
;
53 for (it
= baseObject::mpObjects
->begin (); it
!= baseObject::mpObjects
->end (); it
++)
55 fprintf (stderr
, "memory leak: id=%Xh, refc=%d ptr=%Xh, name='%s', data='", (*it
).first
, (*it
).second
->mRefc
, (*it
).second
, (*it
).second
->name ());
56 for (int i
= 0; i
< 20; i
++)
59 uchar c
= ( (char*) ((*it
).second
))[i
];
61 fprintf (stderr
, "%c", ( (char*) ((*it
).second
))[i
]);
63 fprintf (stderr
, ".");
66 fprintf (stderr
, ".");
69 fprintf (stderr
, "'\n");
73 baseObject::~baseObject (void)
75 std::map
< int, baseObject
* >::iterator it
;
76 it
= mpObjects
->find (mId
);
77 assert (it
!= mpObjects
->end ());
78 mpObjects
->erase (it
);
79 if (mpObjects
->empty ())
86 baseObject::baseObject (void)
89 mpObjects
= new std::map
< int, baseObject
* >;
92 (*mpObjects
)[ mId
] = this;
97 void baseObject::addRef (void)
99 // fprintf (stderr, "object %s addreffed to %d\n", mName.c_str (), mRefc);
103 void baseObject::release (void)
105 // <= is intentional -- client may prefer to not using smartpointers and refcounting
108 // fprintf (stderr, "object %s released to %d\n", mName.c_str (), mRefc);
113 const char* baseObject::name (void) const
118 void baseObject::setName (const char *nm
)
123 bool baseObject::isUsed (void) const
125 // mbUsed flag must be set by resource mgr when non-parser creation method is used
126 // reference counter is remembered at the moment
127 // when refc reaches the same value "used" flag is being reset to 0
128 return mRefc
> 1 ? true : false;
131 void baseObject::loadData (void)
135 bool baseObject::isValid (void) const
141 bool baseObject::isTypeOf (int type
) const