and added files
[bcm963xx.git] / userapps / opensource / net-snmp / include / net-snmp / library / factory.h
1 #ifndef NETSNMP_FACTORY_H
2 #define NETSNMP_FACTORY_H
3
4
5 #ifdef __cplusplus
6 extern "C" {
7 #endif
8
9     typedef void * (netsnmp_factory_produce_f)(void);
10     typedef int (netsnmp_factory_produce_noalloc_f)(void *);
11
12     typedef struct netsnmp_factory_s {
13         /*
14          * a string describing the product the factory creates
15          */
16         const char                           *product;
17
18         /*
19          * a function to create an object in newly allcoated memory
20          */
21         netsnmp_factory_produce_f            *produce;
22
23         /*
24          * a function to create an object in previously allcoated memory
25          */
26         netsnmp_factory_produce_noalloc_f    *produce_noalloc;
27
28     } netsnmp_factory;
29
30     /*
31      * init factory registry
32      */
33     void netsnmp_factory_init(void);
34
35     /*
36      * register a factory type
37      */
38     int  netsnmp_factory_register(netsnmp_factory *f);
39
40     /*
41      * get a factory
42      */
43     netsnmp_factory* netsnmp_factory_get(const char* product);
44
45     /*
46      * ask a factory to produce an object
47      */
48     void * netsnmp_factory_produce(const char* product);
49
50     /*
51      * ask a factory to produce an object in the provided memory
52      */
53     int netsnmp_factory_produce_noalloc(const char *product, void *memory);
54
55     /*
56      * factory return codes
57      */
58     enum {
59         FACTORY_NOERROR = 0,
60         FACTORY_EXISTS,
61         FACTORY_NOTFOUND,
62         FACTORY_NOMEMORY,
63         FACTORY_GENERR,
64         FACTORY_MAXIMUM_ERROR
65     };
66
67 #ifdef __cplusplus
68 };
69 #endif
70
71
72 #endif /* NETSNMP_FACTORY_H */