|
Cheat Engine The Official Site of Cheat Engine
|
View previous topic :: View next topic |
Author |
Message |
benlue Moderator Reputation: 0
Joined: 09 Oct 2006 Posts: 2142
|
Posted: Sat Mar 24, 2007 6:30 am Post subject: Template Managers |
|
|
This is a little tutorial on template managers .
What are managers ?
They are used to manage data and save much time so one code doesn't need to be re-written .
Simple Template Manager
The Interface:
Code: | template <class T, int n> class TManager
{
public:
TManager(void);
~TManager(void);
int Add(const T* p_T);
int Delete(const T* p_T);
int Delete(int index);
int DeleteAll();
T* Get(int index);
T* Get(const T* p_T);
Int GetCount();
int GetError();
char *GetErrorString();
protected:
int error;
T* p_T[n];
};
|
Most functions perform rather obvious operations, although the last three functions might seem strange . These functions really aren't required but I used them anyway . The GetCount() function returns the maximum number of objects that can be managed by this class . The GetError() function returns an error code if one of the previously called functions failed . Normally I just give functions two types of return values - one indicates success and one indicates failure . On failure I then call the GetError() function to retrieve the error .
Singleton
This is the more complex .
Code: | template <class T, int n> class TPersistentManager
{
public:
TPersistentManager(void);
~TPersistentManager(void);
int Add(const T* p_T);
int Delete(const T* p_T);
int Delete(int index);
int DeleteAll();
T* Get(int index);
T* Get(const T* p_T);
Int GetCount();
int GetError();
char *GetErrorString();
private:
static int refcount;
static TManager<T, n> *p_m_tManager;
};
// Note that you MUST initialize these for correct functionality
template <class T, int n> int TPersistentManager<T, n>::refcount = 0;
template <class T, int n> TManager<T, n>* TPersistentManager<T, n>::p_m_tManager = 0x00000000;
template <class T, int n>
TPersistentManager<T, n>::TPersistentManager(void)
{
if(refcount == 0)
{
p_m_tManager = new TManager<T, n>;
}
refcount++;
}
template <class T, int n>
TPersistentManager<T, n>::~TPersistentManager(void)
{
refcount--;
if(refcount == 0)
{
delete p_m_tManager;
p_m_tManager = 0x00000000;
}
}
template <class T, int n>
int TPersistentManager<T, n>::Add(const T* p_T)
{
return p_m_tManager->Add(p_T);
}
// .
// . Rest of code omitted… see the attached code files
// .
template <class T, int n>
char *TPersistentManager<T, n>::GetErrorString()
{
return p_m_tManager->GetErrorString();
}
|
This makes sure that there is only one TManager pointer in the TPersistentManager template . It also redirects all functions to use that TManager class for performing its actions .
Using It
This is how to use it . ( Please figure this out or it will be spoonfeeding )
Code: | class CImageSystem : public TPersistentManager<CImage, 128>
{
public:
CImageSystem();
~CImageSystem();
. // Functions you want to make specific for the CImageSystem class
.
.
}
|
My Words
I do not expect perfection so this isn't great as you may know of me , if you don't get it , read it again or just ditch it like all the failures out there .
That's all .
|
|
Back to top |
|
|
DeltaFlyer Grandmaster Cheater Reputation: 0
Joined: 22 Jul 2006 Posts: 666
|
Posted: Sat Mar 24, 2007 10:33 am Post subject: |
|
|
I don't see a use for this.
_________________
Wow.... still working at 827... what's INCA thinking?
zomg l33t hax at this place (IE only). Over 150 people have used it, what are YOU waiting for? |
|
Back to top |
|
|
benlue Moderator Reputation: 0
Joined: 09 Oct 2006 Posts: 2142
|
Posted: Sat Mar 24, 2007 6:53 pm Post subject: |
|
|
Well , many people attempt to make a maplestory private server . I'm just saving them time . OR this could be used in other ways .
|
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
|
|