WvStreams
|
00001 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- 00002 * 00003 * XPLC - Cross-Platform Lightweight Components 00004 * Copyright (C) 2003, Net Integration Technologies, Inc. 00005 * Copyright (C) 2003, Pierre Phaneuf 00006 * 00007 * This library is free software; you can redistribute it and/or 00008 * modify it under the terms of the GNU Lesser General Public License 00009 * as published by the Free Software Foundation; either version 2.1 of 00010 * the License, or (at your option) any later version. 00011 * 00012 * This library is distributed in the hope that it will be useful, but 00013 * WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00015 * Lesser General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU Lesser General Public 00018 * License along with this library; if not, write to the Free Software 00019 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 00020 * USA 00021 */ 00022 00023 #include <assert.h> 00024 #include <xplc/utils.h> 00025 #include <xplc/uuidops.h> 00026 #include "catmgr.h" 00027 #include "category.h" 00028 00029 UUID_MAP_BEGIN(CategoryManager) 00030 UUID_MAP_ENTRY(IObject) 00031 UUID_MAP_ENTRY(ICategoryManager) 00032 UUID_MAP_END 00033 00034 CategoryManager::CategoryManager(): 00035 categories(0) { 00036 } 00037 00038 CategoryManager::~CategoryManager() { 00039 if(categories) 00040 delete categories; 00041 } 00042 00043 void CategoryManager::registerComponent(const UUID& aCatid, 00044 const UUID& aUuid, 00045 const char* aString) { 00046 CategoryNode* cat; 00047 CategoryEntryNode* entry; 00048 00049 for(cat = categories; cat; cat = cat->next) { 00050 if(cat->category == aCatid) 00051 break; 00052 } 00053 00054 if(!cat) { 00055 cat = new CategoryNode(aCatid, categories); 00056 categories = cat; 00057 } 00058 00059 assert(cat); 00060 00061 for(entry = cat->entries; entry; entry = entry->next) { 00062 if(entry->entry == aUuid) 00063 return; 00064 } 00065 00066 entry = new CategoryEntryNode(aUuid, aString, cat->entries); 00067 assert(entry); 00068 00069 cat->entries = entry; 00070 } 00071 00072 ICategory* CategoryManager::getCategory(const UUID& aUuid) { 00073 CategoryNode* cat; 00074 00075 for(cat = categories; cat; cat = cat->next) { 00076 if(cat->category == aUuid) 00077 return new Category(this, cat->entries); 00078 } 00079 00080 return new Category(this, NULL); 00081 } 00082