2003/10/21
C++ Datatype Access Counter
Hm, would it be possible to create a template, which overloads the default modification-operators of any datatype/class to be able to track the changes made to a variable?
Of course you couldn't track the custom methods of each datatype, but you could follow the changes through the standard methods.
I'm thinking of something like this (rough draft-code):
template class X {
int counter:
public:
T(){counter=0;}
T& operator=(T& t){counter++; return T::operator=(t);}
T& operator+=(T& t){counter++; return T::operator+=(t);}
T& operator-=(T& t){counter++; return T::operator-=(t);}
T& operator++(){counter++; return T::operator++();}
T& operator++(T&){counter++; return T::operator++(T);}
T& operator--(){counter++; return T::operator--();}
T& operator--(T&){counter++; return T::operator--(T);}
int getAccessCounter(){return counter}
};
Note, that I don't need to overload those operators, which return a copy of the object, because they don't modify the original object.
Then you could replace the variable you want to access-count with this template and at the end of your application you just fetch out the counter.
I still have some doubts that something like this works, but I'm not quite sure, why and how this would fail...
Hm, would it be possible to create a template, which overloads the default modification-operators of any datatype/class to be able to track the changes made to a variable?
Of course you couldn't track the custom methods of each datatype, but you could follow the changes through the standard methods.
I'm thinking of something like this (rough draft-code):
template
int counter:
public:
T(){counter=0;}
T& operator=(T& t){counter++; return T::operator=(t);}
T& operator+=(T& t){counter++; return T::operator+=(t);}
T& operator-=(T& t){counter++; return T::operator-=(t);}
T& operator++(){counter++; return T::operator++();}
T& operator++(T&){counter++; return T::operator++(T);}
T& operator--(){counter++; return T::operator--();}
T& operator--(T&){counter++; return T::operator--(T);}
int getAccessCounter(){return counter}
};
Note, that I don't need to overload those operators, which return a copy of the object, because they don't modify the original object.
Then you could replace the variable you want to access-count with this template and at the end of your application you just fetch out the counter.
I still have some doubts that something like this works, but I'm not quite sure, why and how this would fail...
2003/09/02
IPX over TCP Emulator.
It would be nice, if there were a free IPX emulator which could emulate the LAN even over the internet. There are already such products, as Kali and Khan but both have their flaws: Kali is not free, and Khan does not work on Win2k and upwards.
With this it would be able to play older games which only have LAN-Support over IPX over the internet. There are also some more recent games which have multiplayer ability over internet but just over central servers (such as Worms Armageddon) and the LAN-mode just has no possibility to manually set a server ip.
Starcraft and many other Blizzard games are a good example for this.
Anyone out there who is interested in helping me with a new sf.net-Project?
It would be nice, if there were a free IPX emulator which could emulate the LAN even over the internet. There are already such products, as Kali and Khan but both have their flaws: Kali is not free, and Khan does not work on Win2k and upwards.
With this it would be able to play older games which only have LAN-Support over IPX over the internet. There are also some more recent games which have multiplayer ability over internet but just over central servers (such as Worms Armageddon) and the LAN-mode just has no possibility to manually set a server ip.
Starcraft and many other Blizzard games are a good example for this.
Anyone out there who is interested in helping me with a new sf.net-Project?
2003/06/16
Judy Arrays as STL-Containers.
Would it be possible to build a STL-container-framework around JudySL and use it like a standard std::map without any further changes anywhere in the source?
This container has to support at least iterators, find() and operator[] to be minimally useful. Of course the more code is in the container, the smaller is the benefit of Judy.
An example framework can be seen at this Template List Class implementation.
Would it be possible to build a STL-container-framework around JudySL and use it like a standard std::map without any further changes anywhere in the source?
This container has to support at least iterators, find() and operator[] to be minimally useful. Of course the more code is in the container, the smaller is the benefit of Judy.
An example framework can be seen at this Template List Class implementation.
2003/06/15
Booting...
This is the beginning of an idea-collecting blog.
Most ideas will be about programming and designing in the C/C++ language, but from time to time it could be possible that ideas concerning totally other topics can be put down here.
Most ideas will be about programming and designing in the C/C++ language, but from time to time it could be possible that ideas concerning totally other topics can be put down here.