BasicItem:
authormishas <mikhail.sobolev@gmail.com>
Fri, 21 Sep 2007 10:07:25 +0000 (10:07 +0000)
committermishas <mikhail.sobolev@gmail.com>
Fri, 21 Sep 2007 10:07:25 +0000 (10:07 +0000)
* added new virtual method -- load -- to perform the actual initialization
BasicItemFactory:
* implemented 'create' method

git-svn-id: file:///svnroot/simple-launcher/trunk@235 3ba93dab-e023-0410-b42a-de7732cf370a

misc/BasicItem.cc
misc/BasicItem.h

index f6ec384..ee6f817 100644 (file)
 BasicItemFactory::BasicItemFactory() {
   registerFactory(factoryName(), this);
 }
 BasicItemFactory::BasicItemFactory() {
   registerFactory(factoryName(), this);
 }
+
+BasicItem *BasicItemFactory::create(const std::string& factoryName, const std::string& itemID) {
+       BasicItemFactory *factory = ourFactories.find(factoryName);
+       BasicItem *result = NULL;
+
+       if (factory != NULL) {
+               result = factory->createItem(itemID);
+
+               if (result != NULL) {
+                       if (!result->load()) {
+                               delete result;
+
+                               result = NULL;
+                       }
+               }
+       }
+
+       return result;
+}
index 037f9b3..d38a5fa 100644 (file)
@@ -31,6 +31,8 @@ public:
        const std::string& getType() const { return myType; }
        const std::string& getID() const { return myID; }
 
        const std::string& getType() const { return myType; }
        const std::string& getID() const { return myID; }
 
+  virtual bool load() = 0;
+
   virtual std::string getName() const = 0;
   virtual std::string getComment() const = 0;
   virtual GdkPixbuf *getIcon(int iconSize) const = 0;
   virtual std::string getName() const = 0;
   virtual std::string getComment() const = 0;
   virtual GdkPixbuf *getIcon(int iconSize) const = 0;