Files
wagic/projects/mtg/include/MTGCard.h
T
wrenczes@gmail.com bd56723bc0 Checkpoint on a utility helper class. Basically, if you have a class that you want to count the numbers of instances, you do this:
class Foo
#ifdef TRACK_OBJECT_USAGE
      : public InstanceCounter<Foo>
#endif

Then, use this macro somewhere in the class body:
SUPPORT_OBJECT_ANALYTICS(Foo)

Lastly, add whatever information you want to trace out to the function ObjectAnalytics::DumpStatistics().

Here's a sample of the output of what I've instrumented so far:

-----------------------------------------------------------
Object Usage Stats

CardPrimitive current count: 7899
CardPrimitive current byte usage: 2053740
CardPrimitive max count: 7908
CardPrimitive max byte usage: 2056080

MTGCard current count: 13973
MTGCard current byte usage: 670704
MTGCard max count: 13982
MTGCard max byte usage: 671136

MTGCardInstance current count: 180
MTGCardInstance current byte usage: 172080
MTGCardInstance max count: 189
MTGCardInstance max byte usage: 180684

-----------------------------------------------------------
2011-04-23 05:16:53 +00:00

58 lines
1023 B
C++

#ifndef _MTGCARD_H_
#define _MTGCARD_H_
#define MTGCARD_NAME_SIZE 16
#define MTG_IMAGE_WIDTH 200
#define MTG_IMAGE_HEIGHT 285
#define MTG_MINIIMAGE_WIDTH 45
#define MTG_MINIIMAGE_HEIGHT 64
#include <string>
#include <vector>
#include <map>
#include "ObjectAnalytics.h"
class CardPrimitive;
using namespace std;
class MTGCard
#ifdef TRACK_OBJECT_USAGE
: public InstanceCounter<MTGCard>
#endif
{
protected:
friend class MTGSetInfo;
int mtgid;
char rarity;
char image_name[MTGCARD_NAME_SIZE];
vector<string> mFormattedText;
int init();
public:
int setId;
CardPrimitive * data;
MTGCard();
MTGCard(int set_id);
MTGCard(MTGCard * source);
virtual ~MTGCard();
void setMTGId(int id);
void setRarity(char _rarity);
//void setImageName( char * value);
void setPrimitive(CardPrimitive * cp);
const vector<string>& GetFormattedText();
int getMTGId() const;
int getId() const;
char getRarity() const;
char * getImageName();
};
#endif