Go to the documentation of this file.00001
00002 #ifdef VCL_NEEDS_PRAGMA_INTERFACE
00003 #pragma implementation
00004 #endif
00005
00006
00007
00008
00009 #include "osl_topology.h"
00010 #include <vcl_new.h>
00011 #include <vcl_cstring.h>
00012 #include <osl/osl_hacks.h>
00013
00014
00015
00016 #define ALLOW_CORELEAKS 0
00017
00018
00019 #define fsm_pad
00020
00021
00022
00023 struct osl_stash_link {
00024 osl_stash_link(char const *name_, void const *data_, void (*dtor_)(void*), osl_stash_link *next_)
00025 : name(name_), data(const_cast<void*>(data_)), dtor(dtor_), next(next_) { }
00026 char const *name;
00027 void *data;
00028 void (*dtor)(void *);
00029 osl_stash_link *next;
00030 };
00031
00032 osl_topology_base::osl_topology_base() : id(0), stash_head(0) { }
00033 void osl_topology_base::stash_add(char const *name,
00034 void const *data,
00035 void (*dtor)(void *))
00036 {
00037 osl_stash_link *l = new osl_stash_link(name, data, dtor, stash_head);
00038 stash_head = l;
00039 }
00040
00041 void osl_topology_base::stash_replace(char const *name,
00042 void const *data,
00043 void (*dtor)(void *))
00044 {
00045 for (osl_stash_link *l = stash_head; l; l=l->next) {
00046 if (vcl_strcmp(l->name, name) == 0) {
00047 l->name = name;
00048 l->data = const_cast<void*>(data);
00049 l->dtor = dtor;
00050 return;
00051 }
00052 }
00053
00054 stash_add(name, data, dtor);
00055 }
00056
00057 void *osl_topology_base::stash_retrieve(char const *name) const {
00058 for (osl_stash_link *l = stash_head; l; l=l->next)
00059 if (vcl_strcmp(l->name, name) == 0)
00060 return l->data;
00061
00062 return 0;
00063 }
00064
00065 void *osl_topology_base::stash_remove(char const *name) {
00066 for (osl_stash_link *p = 0, *l = stash_head; l; p=l, l=p->next) {
00067 if (vcl_strcmp(l->name, name) == 0) {
00068 if (p)
00069 p->next = l->next;
00070 else
00071 stash_head = l->next;
00072 delete l;
00073 }
00074 }
00075
00076 return 0;
00077 }
00078
00079 osl_topology_base::~osl_topology_base() {
00080 while (stash_head) {
00081 if (stash_head->dtor)
00082 (stash_head->dtor)(stash_head->data);
00083 stash_remove(stash_head->name);
00084 }
00085 }
00086
00087 void osl_topology_base::SetId(int v) { id = v; }
00088
00089 int osl_topology_base::GetId() const { return id; }
00090
00091