ruby: apply some fixes that were overwritten by the recent ruby import.
[gem5.git] / src / mem / gems_common / RefCountable.hh
1 /*
2 * Copyright (c) 1999-2005 Mark D. Hill and David A. Wood
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;
9 * redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution;
12 * neither the name of the copyright holders nor the names of its
13 * contributors may be used to endorse or promote products derived from
14 * this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29 /*
30 * Virtual base class for things that can be reference counted
31 */
32
33 #ifndef REFCOUNTABLE_H
34 #define REFCOUNTABLE_H
35
36 #include "mem/gems_common/RefCnt.hh"
37
38 class RefCountable {
39 public:
40 // Public Methods
41
42 RefCountable() { m_refcnt = 0; }
43
44 // These are used by the RefCnt class to hold the reference count
45 // for the object. These really should be private and accessed by a
46 // friend class, but I can't figure out how to make a template class
47 // a friend.
48 void incRefCnt() { m_refcnt++; }
49 void decRefCnt() { m_refcnt--; }
50 int getRefCnt() const { return m_refcnt; }
51 void setRefCnt(int cnt) { m_refcnt = cnt; }
52 private:
53 // Private Methods
54
55 // Data Members (m_ prefix)
56 int m_refcnt;
57 };
58
59 #endif //REFCOUNTABLE_H