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
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>
* </code></pre>
*
* For detais of the testStorage element, see the documentation for the
* TestStorageClient class.
* or:
*
* <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:
*
* <pre><code>
* &lt;!ELEMENT storageClientFactory (testStorage) &gt;
* <!ELEMENT storageClientFactory (testStorage|webStorage) >
* </code></pre>
*
* @author $Author: fgerlits $
* @version $Revision: 1.4 $
* @author $Author: maroy $
* @version $Revision: 1.5 $
* @see TestStorageClient
* @see WebStorageClient
*/
class StorageClientFactory :
virtual public Configurable

View File

@ -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<const xmlpp::Element*> (*(nodes.begin()));
Ptr<TestStorageClient>::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<const xmlpp::Element*> (*(nodes.begin()));
Ptr<WebStorageClient>::Ref wsc(new WebStorageClient());
wsc->configure(*configElement);
storageClient = wsc;
return;
}
throw std::invalid_argument("no storage client factories to configure");
}