added WebStorageClient to StorageClientFactory

This commit is contained in:
maroy 2004-12-02 10:30:02 +00:00
parent 2ae50400d4
commit c5f2579ec9
2 changed files with 36 additions and 14 deletions

View File

@ -21,8 +21,8 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Author : $Author: fgerlits $ Author : $Author: maroy $
Version : $Revision: 1.4 $ Version : $Revision: 1.5 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storage/include/LiveSupport/Storage/StorageClientFactory.h,v $ 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 * This object has to be configured with an XML configuration element
* called storageClientFactory. This element contains a child element * called storageClientFactory. This element contains a child element
* specifying and configuring the kind of StorageClient that the * 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: * A storageClientFactory configuration element may look like the following:
* *
@ -78,18 +79,29 @@ using namespace LiveSupport::Core;
* </storageClientFactory> * </storageClientFactory>
* </code></pre> * </code></pre>
* *
* For detais of the testStorage element, see the documentation for the * or:
* TestStorageClient class. *
* <pre><code>
* &lt;storageClientFactory&gt;
* &lt;webStorage&gt;
* ...
* &lt;/webStorage&gt;
* &lt;/storageClientFactory&gt;
* </code></pre>
*
* For detais of the respective elements, see the documentation for the
* TestStorageClient and WebStorageClient classes.
* *
* The DTD for the above element is: * The DTD for the above element is:
* *
* <pre><code> * <pre><code>
* &lt;!ELEMENT storageClientFactory (testStorage) &gt; * <!ELEMENT storageClientFactory (testStorage|webStorage) >
* </code></pre> * </code></pre>
* *
* @author $Author: fgerlits $ * @author $Author: maroy $
* @version $Revision: 1.4 $ * @version $Revision: 1.5 $
* @see TestStorageClient * @see TestStorageClient
* @see WebStorageClient
*/ */
class StorageClientFactory : class StorageClientFactory :
virtual public Configurable virtual public Configurable

View File

@ -21,8 +21,8 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Author : $Author: fgerlits $ Author : $Author: maroy $
Version : $Revision: 1.3 $ Version : $Revision: 1.4 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storage/src/StorageClientFactory.cxx,v $ 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(); storageClient.reset();
xmlpp::Node::NodeList nodes;
// try to look for a TestStorageClient configuration element // try to look for a TestStorageClient configuration element
xmlpp::Node::NodeList nodes = nodes = element.get_children(TestStorageClient::getConfigElementName());
element.get_children(TestStorageClient::getConfigElementName());
if (nodes.size() >= 1) { if (nodes.size() >= 1) {
const xmlpp::Element * configElement = const xmlpp::Element * configElement =
dynamic_cast<const xmlpp::Element*> (*(nodes.begin())); dynamic_cast<const xmlpp::Element*> (*(nodes.begin()));
Ptr<TestStorageClient>::Ref tsc(new TestStorageClient()); Ptr<TestStorageClient>::Ref tsc(new TestStorageClient());
tsc->configure(*configElement); tsc->configure(*configElement);
storageClient = tsc; storageClient = tsc;
return;
}
// try to look for a WebStorageClient configuration element
nodes = element.get_children(WebStorageClient::getConfigElementName());
if (nodes.size() >= 1) {
const xmlpp::Element * configElement =
dynamic_cast<const xmlpp::Element*> (*(nodes.begin()));
Ptr<WebStorageClient>::Ref wsc(new WebStorageClient());
wsc->configure(*configElement);
storageClient = wsc;
return;
} }
if (!storageClient) {
throw std::invalid_argument("no storage client factories to configure"); throw std::invalid_argument("no storage client factories to configure");
} }
}