WvStreams
catmgr.cc
1/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 *
3 * XPLC - Cross-Platform Lightweight Components
4 * Copyright (C) 2003, Net Integration Technologies, Inc.
5 * Copyright (C) 2003, Pierre Phaneuf
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public License
9 * as published by the Free Software Foundation; either version 2.1 of
10 * the License, or (at your option) any later version.
11 *
12 * This library is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
20 * USA
21 */
22
23#include <assert.h>
24#include <xplc/utils.h>
25#include <xplc/uuidops.h>
26#include "catmgr.h"
27#include "category.h"
28
33
34CategoryManager::CategoryManager():
35 categories(0) {
36}
37
38CategoryManager::~CategoryManager() {
39 if(categories)
40 delete categories;
41}
42
44 const UUID& aUuid,
45 const char* aString) {
46 CategoryNode* cat;
47 CategoryEntryNode* entry;
48
49 for(cat = categories; cat; cat = cat->next) {
50 if(cat->category == aCatid)
51 break;
52 }
53
54 if(!cat) {
55 cat = new CategoryNode(aCatid, categories);
56 categories = cat;
57 }
58
59 assert(cat);
60
61 for(entry = cat->entries; entry; entry = entry->next) {
62 if(entry->entry == aUuid)
63 return;
64 }
65
66 entry = new CategoryEntryNode(aUuid, aString, cat->entries);
67 assert(entry);
68
69 cat->entries = entry;
70}
71
73 CategoryNode* cat;
74
75 for(cat = categories; cat; cat = cat->next) {
76 if(cat->category == aUuid)
77 return new Category(this, cat->entries);
78 }
79
80 return new Category(this, NULL);
81}
82
virtual void registerComponent(const UUID &, const UUID &, const char *)
Register a component with a category.
Definition catmgr.cc:43
virtual ICategory * getCategory(const UUID &)
Get a category object for the specified category.
Definition catmgr.cc:72
Let you register categories and obtain information about them.
The basic interface which is included by all other XPLC interfaces and objects.
#define UUID_MAP_END
Marks the end of an interface map.
#define UUID_MAP_BEGIN(component)
Start the interface map for "component".
#define UUID_MAP_ENTRY(iface)
Add an entry to an interface map.