diff options
author | cathook <b01902109@csie.ntu.edu.tw> | 2014-04-19 23:39:29 +0800 |
---|---|---|
committer | cathook <b01902109@csie.ntu.edu.tw> | 2014-04-19 23:39:29 +0800 |
commit | c3ddd993afbdfe37e85df4a54738469dcbc0a37c (patch) | |
tree | 06c56613d6dc5189f4ac3535507d8fdd6a761643 /meowpp/oo | |
parent | e9a16c4ef0ea782d7db8d788c455ea946eaab039 (diff) | |
download | meow-c3ddd993afbdfe37e85df4a54738469dcbc0a37c.tar meow-c3ddd993afbdfe37e85df4a54738469dcbc0a37c.tar.gz meow-c3ddd993afbdfe37e85df4a54738469dcbc0a37c.tar.bz2 meow-c3ddd993afbdfe37e85df4a54738469dcbc0a37c.tar.lz meow-c3ddd993afbdfe37e85df4a54738469dcbc0a37c.tar.xz meow-c3ddd993afbdfe37e85df4a54738469dcbc0a37c.tar.zst meow-c3ddd993afbdfe37e85df4a54738469dcbc0a37c.zip |
Add description
Diffstat (limited to 'meowpp/oo')
-rw-r--r-- | meowpp/oo/Register_Implement.h | 20 | ||||
-rw-r--r-- | meowpp/oo/Register_Implement.hpp | 5 |
2 files changed, 22 insertions, 3 deletions
diff --git a/meowpp/oo/Register_Implement.h b/meowpp/oo/Register_Implement.h index e46f86c..dd496fa 100644 --- a/meowpp/oo/Register_Implement.h +++ b/meowpp/oo/Register_Implement.h @@ -26,6 +26,26 @@ namespace meow{ virtual ImplementInterface<T>* getImplement(T const& identify); virtual ~RegisterInterface(){ } }; + /******************************************************************* + @asciidoc + === meow:: *ImplementInterface/RegisterInterface* (C++ Class) + .Description + Assume there is a problem which can be solved by different algorithms. + Then you can write multiple classes to approach this problem. + + Now if you want to decide which algorithm to use in runtime, you can just + approach this case by a simple way: + + * Let all the problem-solving classes inherit from + `class ImplementInterface<T>` , and call the constructure with giving + `identify` (type `T` ) . + * Create an object, type `RegisterInterface<T>` , and register all your + implement class to it by call `regImplement(pointer to the class)`. + * Select which implement class you want by call `getImplement(identify)` , + which will return the pointer to the corresponding class. + + ''' + @asciidoc- + ******************************************************************/ } #include "Register_Implement.hpp" diff --git a/meowpp/oo/Register_Implement.hpp b/meowpp/oo/Register_Implement.hpp index 523f266..34d9129 100644 --- a/meowpp/oo/Register_Implement.hpp +++ b/meowpp/oo/Register_Implement.hpp @@ -13,9 +13,8 @@ namespace meow{ return true; } template<class T> - inline ImplementInterface<T>* RegisterInterface<T>::getImplement( - T const& identify - ){ + inline ImplementInterface<T>* + RegisterInterface<T>::getImplement(T const& identify){ if(implements.find(identify) == implements.end()){ return NULL; } |