| 244 | } |
| 245 | |
| 246 | void test_interface() |
| 247 | { |
| 248 | SpecificFactory<base>* p_fc = SpecificFactory<base>::GetFactory(); |
| 249 | |
| 250 | p_fc->RegisterInterface<A>("A"); |
| 251 | p_fc->RegisterInterface<A, int>("A"); |
| 252 | p_fc->RegisterInterface<B>("B"); |
| 253 | p_fc->RegisterInterface<B, int>("B"); |
| 254 | p_fc->RegisterInterface<B, int, const std::string&>("B"); |
| 255 | p_fc->RegisterInterface<B, int, std::string&&>("B"); |
| 256 | |
| 257 | std::cout << "Now, test create...\n"; |
| 258 | |
| 259 | base* p_base; |
| 260 | |
| 261 | p_base = p_fc->Create("A"); |
| 262 | p_base->f(); |
| 263 | |
| 264 | p_base = p_fc->Create("A", 102); |
| 265 | p_base->f(); |
| 266 | |
| 267 | const std::string& str = "lval"; |
| 268 | p_base = p_fc->Create("B", 100, str); |
| 269 | |
| 270 | p_base->f(); |
| 271 | p_base->g(); |
| 272 | |
| 273 | p_base = p_fc->Create<int, std::string&&>("B", 200, "rval"); |
| 274 | |
| 275 | p_base->f(); |
| 276 | p_base->g(); |
| 277 | } |
| 278 | |
| 279 | int main(void) |
| 280 | { |