BasicItem:
[simple-launcher] / misc / BasicItem.cc
1 // This file is a part of Simple Launcher
2 //
3 // Copyright (C) 2006, 2007, Mikhail Sobolev
4 //
5 // Simple Launcher is free software; you can redistribute it and/or modify it
6 // under the terms of the GNU General Public License version 2 as published by
7 // the Free Software Foundation.
8 //
9 // This program is distributed in the hope that it will be useful, but WITHOUT
10 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 // FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
12 // more details.
13 //
14 // You should have received a copy of the GNU General Public License along with
15 // this program; if not, write to the Free Software Foundation, Inc., 51
16 // Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
17
18 #include "BasicItem.h"
19
20 BasicItemFactory::BasicItemFactory() {
21   registerFactory(factoryName(), this);
22 }
23
24 BasicItem *BasicItemFactory::create(const std::string& factoryName, const std::string& itemID) {
25         BasicItemFactory *factory = ourFactories.find(factoryName);
26         BasicItem *result = NULL;
27
28         if (factory != NULL) {
29                 result = factory->createItem(itemID);
30
31                 if (result != NULL) {
32                         if (!result->load()) {
33                                 delete result;
34
35                                 result = NULL;
36                         }
37                 }
38         }
39
40         return result;
41 }