1 |
|
// -*- mode: C++; tab-width: 4; indent-tabs-mode: t; -*- vim:ts=4:sw=4 |
2 |
|
// |
3 |
|
// Copyright (C) 2004 David Lau (skunix) |
4 |
|
// Chong Kai Xiong (descender) |
5 |
|
// |
6 |
|
// This file is part of The Plains of Usata. |
7 |
|
// |
8 |
|
// The Plains of Usata is licensed under the GNU General Public |
9 |
|
// License (GPL) version 2. For details, please see the COPYING file |
10 |
|
// included in the software distribution, or visit |
11 |
|
// http://www.fsf.org/licenses/gpl.html. |
12 |
|
// |
13 |
|
// $Id$ |
14 |
|
|
15 |
|
|
16 |
#ifndef USATA_OBJECT_REGISTRY |
#ifndef USATA_OBJECT_REGISTRY |
17 |
#define USATA_OBJECT_REGISTRY |
#define USATA_OBJECT_REGISTRY |
18 |
#include <memory> |
#include <memory> |
19 |
|
/** |
20 |
|
\defgroup objreg ObjectRegistry |
21 |
|
**/ |
22 |
namespace usata |
namespace usata |
23 |
{ |
{ |
24 |
|
|
25 |
class Object; |
class Object; |
26 |
|
//! Built In Object Creation Function |
27 |
typedef Object* (*BIOCF)(void);// BIOCF; |
typedef Object* (*BIOCF)(void);// BIOCF; |
28 |
|
|
29 |
struct ObjectRegistryImpl; |
struct ObjectRegistryImpl; |
30 |
|
//! Singleton to assist in the creation of Object based classes referenced by name |
31 |
|
/** |
32 |
|
\ingroup objreg |
33 |
|
**/ |
34 |
class ObjectRegistry |
class ObjectRegistry |
35 |
{ |
{ |
36 |
static std::auto_ptr<ObjectRegistry> mInstance; |
static std::auto_ptr<ObjectRegistry> mInstance; |
39 |
ObjectRegistry(); |
ObjectRegistry(); |
40 |
|
|
41 |
public: |
public: |
42 |
|
/** \brief get a pointer to the ObjectRegistry |
43 |
|
\todo define characteristics, and exception specs better |
44 |
|
*/ |
45 |
static ObjectRegistry* instance(); |
static ObjectRegistry* instance(); |
46 |
void add(const char*, BIOCF) throw(); |
|
47 |
|
/** |
48 |
|
This function will silently fail if: |
49 |
|
- If object_name.empty() |
50 |
|
- If create_func is 0 |
51 |
|
- If object_name is already used |
52 |
|
|
53 |
|
\brief Associate a string with an Object type |
54 |
|
|
55 |
|
\code |
56 |
|
huh |
57 |
|
\endcode |
58 |
|
**/ |
59 |
|
|
60 |
|
void add(const char* object_name, BIOCF create_func) throw(); |
61 |
|
|
62 |
}; |
}; |
63 |
/** |
/** |