From c5f2579ec97a97a9f0e79ee126773739c2ddc862 Mon Sep 17 00:00:00 2001 From: maroy Date: Thu, 2 Dec 2004 10:30:02 +0000 Subject: [PATCH] added WebStorageClient to StorageClientFactory --- .../Storage/StorageClientFactory.h | 28 +++++++++++++------ .../storage/src/StorageClientFactory.cxx | 22 +++++++++++---- 2 files changed, 36 insertions(+), 14 deletions(-) diff --git a/livesupport/modules/storage/include/LiveSupport/Storage/StorageClientFactory.h b/livesupport/modules/storage/include/LiveSupport/Storage/StorageClientFactory.h index 6783bd74b..07adc89f8 100644 --- a/livesupport/modules/storage/include/LiveSupport/Storage/StorageClientFactory.h +++ b/livesupport/modules/storage/include/LiveSupport/Storage/StorageClientFactory.h @@ -21,8 +21,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - Author : $Author: fgerlits $ - Version : $Revision: 1.4 $ + Author : $Author: maroy $ + Version : $Revision: 1.5 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storage/include/LiveSupport/Storage/StorageClientFactory.h,v $ ------------------------------------------------------------------------------*/ @@ -66,7 +66,8 @@ using namespace LiveSupport::Core; * This object has to be configured with an XML configuration element * called storageClientFactory. This element contains a child element * specifying and configuring the kind of StorageClient that the - * factory builds. Currently only the TestStorageClient is supported. + * factory builds. Currently TestStorageClient and WebStorageClient + * are supported. * * A storageClientFactory configuration element may look like the following: * @@ -78,18 +79,29 @@ using namespace LiveSupport::Core; * </storageClientFactory> * * - * For detais of the testStorage element, see the documentation for the - * TestStorageClient class. + * or: + * + *

+ *  <storageClientFactory>
+ *      <webStorage>
+ *          ...
+ *      </webStorage>
+ *  </storageClientFactory>
+ *  
+ * + * For detais of the respective elements, see the documentation for the + * TestStorageClient and WebStorageClient classes. * * The DTD for the above element is: * *

- *  <!ELEMENT storageClientFactory (testStorage) >
+ *  
  *  
* - * @author $Author: fgerlits $ - * @version $Revision: 1.4 $ + * @author $Author: maroy $ + * @version $Revision: 1.5 $ * @see TestStorageClient + * @see WebStorageClient */ class StorageClientFactory : virtual public Configurable diff --git a/livesupport/modules/storage/src/StorageClientFactory.cxx b/livesupport/modules/storage/src/StorageClientFactory.cxx index 4bce8f591..747ab2034 100644 --- a/livesupport/modules/storage/src/StorageClientFactory.cxx +++ b/livesupport/modules/storage/src/StorageClientFactory.cxx @@ -21,8 +21,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - Author : $Author: fgerlits $ - Version : $Revision: 1.3 $ + Author : $Author: maroy $ + Version : $Revision: 1.4 $ Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storage/src/StorageClientFactory.cxx,v $ ------------------------------------------------------------------------------*/ @@ -93,20 +93,30 @@ StorageClientFactory :: configure(const xmlpp::Element & element) } storageClient.reset(); + xmlpp::Node::NodeList nodes; // try to look for a TestStorageClient configuration element - xmlpp::Node::NodeList nodes = - element.get_children(TestStorageClient::getConfigElementName()); + nodes = element.get_children(TestStorageClient::getConfigElementName()); if (nodes.size() >= 1) { const xmlpp::Element * configElement = dynamic_cast (*(nodes.begin())); Ptr::Ref tsc(new TestStorageClient()); tsc->configure(*configElement); storageClient = tsc; + return; } - if (!storageClient) { - throw std::invalid_argument("no storage client factories to configure"); + // try to look for a WebStorageClient configuration element + nodes = element.get_children(WebStorageClient::getConfigElementName()); + if (nodes.size() >= 1) { + const xmlpp::Element * configElement = + dynamic_cast (*(nodes.begin())); + Ptr::Ref wsc(new WebStorageClient()); + wsc->configure(*configElement); + storageClient = wsc; + return; } + + throw std::invalid_argument("no storage client factories to configure"); }