From 1817d739e89b1d4c1c09d5f553ce5068fab0e4d7 Mon Sep 17 00:00:00 2001 From: cathook Date: Mon, 21 Apr 2014 14:13:53 +0800 Subject: =?UTF-8?q?=E5=A3=93=E5=8A=9B=E6=B8=AC=E8=A9=A6=E5=AE=8C=E6=88=90~?= =?UTF-8?q?~~~~~~~~~?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- meowpp/oo/Register_Implement.h | 4 +++- meowpp/oo/Register_Implement.hpp | 12 +++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) (limited to 'meowpp/oo') diff --git a/meowpp/oo/Register_Implement.h b/meowpp/oo/Register_Implement.h index dd496fa..2e8ca32 100644 --- a/meowpp/oo/Register_Implement.h +++ b/meowpp/oo/Register_Implement.h @@ -2,6 +2,7 @@ #define REGISTER_IMPLEMENT_H_ #include +#include namespace meow{ template @@ -25,6 +26,7 @@ namespace meow{ virtual bool regImplement(ImplementInterface*imp); virtual ImplementInterface* getImplement(T const& identify); virtual ~RegisterInterface(){ } + std::vector getIdentifys() const; }; /******************************************************************* @asciidoc @@ -38,7 +40,7 @@ namespace meow{ * Let all the problem-solving classes inherit from `class ImplementInterface` , and call the constructure with giving `identify` (type `T` ) . - * Create an object, type `RegisterInterface` , and register all your + * Create an class inherit from `RegisterInterface` , 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. diff --git a/meowpp/oo/Register_Implement.hpp b/meowpp/oo/Register_Implement.hpp index 34d9129..206b0a3 100644 --- a/meowpp/oo/Register_Implement.hpp +++ b/meowpp/oo/Register_Implement.hpp @@ -1,5 +1,5 @@ - #include +#include namespace meow{ template @@ -20,4 +20,14 @@ namespace meow{ } return implements[identify]; } + template + inline std::vector + RegisterInterface::getIdentifys() const{ + std::vector ret; + for(typename std::map*>::const_iterator + it = implements.begin(); it != implements.end(); it++){ + ret.push_back(it->first); + } + return ret; + } } -- cgit v1.2.3