Debian Codegraph @

mobref.h

raw symbols SCIP
1 /*
2 * PROPRIETARY INFORMATION. This software is proprietary to POWDER
3 * Development, and is not to be reproduced, transmitted, or disclosed
4 * in any way without written permission.
5 *
6 * Produced by: Jeff Lait
7 *
8 * POWDER Development
9 *
10 * NAME: mobref.h ( POWDER Library, C++ )
11 *
12 * COMMENTS:
13 * Definition for mob references
14 *
15 * These light weight classes use reference counting internally
16 * to allow you to track MOB * without having to worry about
17 * the MOB being deleted (you will then just get 0 back)
18 * It also allows swapping MOB * behind the users back,
19 * potentially compressing MOBs, etc. Also, you can always save/reload
20 * the raw MOBREFs rather than MOB * which don't save & load very well.
21 */
22
23 #ifndef __mobref_h__
24 #define __mobref_h__
25
26 // needed for u16.
27 #include "mygba.h"
28
29 class SRAMSTREAM;
30 class MOB;
31
32 // Required one time initialization.
33 void mobref_init();
34
35 // This wipes all the tables. Do not call if you still have MOBREF
36 // pointers lying around!
37 // It's provided to make it easier to shoot yourself in the foot.
38 void mobref_clearallrefs();
39
40 // Debugging information.
41 int mobref_getnumrefs();
42 int mobref_getnumtables();
43
44 class MOBREF
45 {
46 public:
47 MOBREF();
48 ~MOBREF();
49
50 // Copy constructor & assignment operators.
51 MOBREF(const MOBREF &ref);
52 MOBREF &operator=(const MOBREF &ref);
53
54 void load(SRAMSTREAM &is);
55 void save(SRAMSTREAM &os) const;
56
57 // Clears this reference & then creates a new ref for MOB.
58 // Should only be done by MOB itself!
59 void createAndSetMOB(MOB *mob);
60
61 // Changes the underlying mob * to the new one.
62 // returns false if something really bad happened.
63 bool transferMOB(MOB *mob);
64
65 // Changes our reference to be the given mob's reference. This
66 // handles the pain of dealing with null MOB*.
67 void setMob(const MOB *mob);
68
69 MOB *getMob() const;
70
71 // Returns if the reference is null, NOT if what it points to
72 // is null!
73 bool isNull() const { return myId == 0; }
74
75 // Returns the base id. Should only be used to hash mobs!
76 // Note that these *are* recycled! And change on reload!
77 int getId() const { return myId; }
78
79 private:
80 mutable u16 myId;
81 };
82
83 #endif