00001
00002
00003 #include "xmlUtil/id/IdDictMan.h"
00004 #include "xmlUtil/id/IdDict.h"
00005 #include <algorithm>
00006
00007 namespace xmlUtil {
00008 IdDictMan * IdDictMan::me = 0;
00009
00010 IdDictMan *IdDictMan::getPointer() {
00011 if (me == 0) {
00012 me = new IdDictMan();
00013 }
00014 return me;
00015 }
00016
00017 IdDict *IdDictMan::findDict(std::string name) {
00018 unsigned int ix;
00019
00020 for (ix = 0; ix < dictDir.size(); ix++) {
00021 IdDict *dict = (dictDir)[ix];
00022 if (name.compare(dict->getDictName()) == 0) return dict;
00023 }
00024 return 0;
00025 }
00026
00027 IdDictMan::RetCode IdDictMan::registerDict(IdDict *dict) {
00028
00029 if (findDict(dict->getDictName()) != 0) return DUPLICATE;
00030
00031 dictDir.push_back(dict);
00032 return SUCCESS;
00033 }
00034
00035
00036 IdDictMan::RetCode IdDictMan::removeDict(std::string name) {
00037
00038 IdDict *dict = findDict(name);
00039 if (dict == 0) return NOTFOUND;
00040
00041 std::remove(dictDir.begin(), dictDir.end(), dict);
00042 return SUCCESS;
00043 }
00044
00045
00046 }