Templates -- Meow  1.1.4
A C++ template which is unable and also not allowed to compile to obj-file first.
meow::ObjSelector< id > Class Template Reference

利用register的概念, 達到runtime用string選擇要new的class More...

#include "ObjSelector.h"

Public Member Functions

 ObjSelector (std::string name, ObjBase *obj, bool autoDelete)
 宣告一個ObjSelector實體, 並且註冊一個 ObjBase More...
 
 ObjSelector (ObjBase *obj, bool autoDelete)
 宣告一個ObjSelector實體, 並且註冊一個 ObjBase More...
 
 ~ObjSelector ()
 解構子 More...
 

Static Public Member Functions

static void add (std::string name, ObjBase *obj, bool autoDelete)
 新增(註冊) 一個Class (必須要繼承自 ObjBase) 並且給定其Name More...
 
static void add (ObjBase *obj, bool autoDelete)
 新增(註冊) 一個Class (必須要繼承自 ObjBase) 並且默認type為name More...
 
static void del (std::string name)
 依照name刪除之前註冊過得Class More...
 
static ObjBase const * get (std::string name)
 取得之前註冊過得Class More...
 
static ObjBasecreate (std::string name)
 回傳一個之前註冊過得Class new出來的實體 More...
 
static bool exist (ObjBase *obj)
 利用type檢查是否有註冊過同種類的Class More...
 
static std::string name (ObjBase *obj)
 利用type尋找name More...
 
static std::vector< std::string > names ()
 回傳所有註冊過的name More...
 
static bool write (FILE *f, bool binary, ObjBase *obj, unsigned int fg)
 將一個物件寫到檔案裡(該物件必須要有註冊過) More...
 
static ObjBaseread (FILE *f, bool binary)
 從檔案中讀取一個物件(該物件必須要有註冊過) More...
 

Friends

struct Info
 

Detailed Description

template<size_t id>
class meow::ObjSelector< id >

利用register的概念, 達到runtime用string選擇要new的class

Author
cathook< 讓程式可以有不只一個 ObjSelector

Definition at line 22 of file ObjSelector.h.

Constructor & Destructor Documentation

template<size_t id>
meow::ObjSelector< id >::ObjSelector ( std::string  name,
ObjBase obj,
bool  autoDelete 
)
inline

宣告一個ObjSelector實體, 並且註冊一個 ObjBase

Definition at line 148 of file ObjSelector.h.

template<size_t id>
meow::ObjSelector< id >::ObjSelector ( ObjBase obj,
bool  autoDelete 
)
inline

宣告一個ObjSelector實體, 並且註冊一個 ObjBase

Definition at line 156 of file ObjSelector.h.

template<size_t id>
meow::ObjSelector< id >::~ObjSelector ( )
inline

解構子

Definition at line 162 of file ObjSelector.h.

Member Function Documentation

template<size_t id>
static void meow::ObjSelector< id >::add ( std::string  name,
ObjBase obj,
bool  autoDelete 
)
inlinestatic

新增(註冊) 一個Class (必須要繼承自 ObjBase) 並且給定其Name

Definition at line 69 of file ObjSelector.h.

template<size_t id>
static void meow::ObjSelector< id >::add ( ObjBase obj,
bool  autoDelete 
)
inlinestatic

新增(註冊) 一個Class (必須要繼承自 ObjBase) 並且默認type為name

Definition at line 76 of file ObjSelector.h.

template<size_t id>
static ObjBase* meow::ObjSelector< id >::create ( std::string  name)
inlinestatic

回傳一個之前註冊過得Class new出來的實體

Definition at line 101 of file ObjSelector.h.

template<size_t id>
static void meow::ObjSelector< id >::del ( std::string  name)
inlinestatic

依照name刪除之前註冊過得Class

Definition at line 83 of file ObjSelector.h.

template<size_t id>
static bool meow::ObjSelector< id >::exist ( ObjBase obj)
inlinestatic

利用type檢查是否有註冊過同種類的Class

Definition at line 110 of file ObjSelector.h.

template<size_t id>
static ObjBase const* meow::ObjSelector< id >::get ( std::string  name)
inlinestatic

取得之前註冊過得Class

Definition at line 93 of file ObjSelector.h.

template<size_t id>
static std::string meow::ObjSelector< id >::name ( ObjBase obj)
inlinestatic

利用type尋找name

Definition at line 124 of file ObjSelector.h.

template<size_t id>
static std::vector<std::string> meow::ObjSelector< id >::names ( )
inlinestatic

回傳所有註冊過的name

Definition at line 138 of file ObjSelector.h.

template<size_t id>
static ObjBase* meow::ObjSelector< id >::read ( FILE *  f,
bool  binary 
)
inlinestatic

從檔案中讀取一個物件(該物件必須要有註冊過)

Definition at line 188 of file ObjSelector.h.

template<size_t id>
static bool meow::ObjSelector< id >::write ( FILE *  f,
bool  binary,
ObjBase obj,
unsigned int  fg 
)
inlinestatic

將一個物件寫到檔案裡(該物件必須要有註冊過)

Definition at line 171 of file ObjSelector.h.

Friends And Related Function Documentation

template<size_t id>
friend struct Info
friend

Definition at line 45 of file ObjSelector.h.


The documentation for this class was generated from the following file: