*/\r
\r
/**\r
- * @file ILockable.h\r
+ * @file Lockable.h\r
* \r
* Locking abstraction \r
*/\r
\r
-#if !defined(__xmltooling_lockable_h__)\r
+#ifndef __xmltooling_lockable_h__\r
#define __xmltooling_lockable_h__\r
\r
#include <xmltooling/base.h>\r
/**\r
* Abstract mixin interface for interfaces that support locking\r
*/\r
- struct XMLTOOL_API ILockable\r
+ struct XMLTOOL_API Lockable\r
{\r
- virtual ~ILockable() {}\r
+ virtual ~Lockable() {}\r
\r
/**\r
* Lock the associated object for exclusive access.\r
* \r
* @return a reference to the object being locked\r
*/\r
- virtual ILockable& lock()=0;\r
+ virtual Lockable& lock()=0;\r
\r
/**\r
* Unlock the associated object from exclusive access.\r
* \r
* @param lockee Pointer to an object to lock and hold\r
*/\r
- Locker(ILockable* lockee) : m_lockee(lockee->lock()) {}\r
+ Locker(Lockable* lockee) : m_lockee(lockee->lock()) {}\r
\r
/**\r
* Locks an object and stores it for later release.\r
* \r
* @param lockee Reference to an object to lock and hold\r
*/\r
- Locker(ILockable& lockee) : m_lockee(lockee.lock()) {}\r
+ Locker(Lockable& lockee) : m_lockee(lockee.lock()) {}\r
\r
/**\r
* Releases lock on held pointer, if any.\r
*/\r
~Locker() {m_lockee.unlock();}\r
private:\r
- ILockable& m_lockee;\r
+ Lockable& m_lockee;\r
};\r
\r
};\r
config_pub.h \
ElementProxy.h \
exceptions.h \
- ILockable.h \
+ Lockable.h \
Namespace.h \
+ PluginManager.h \
QName.h \
SimpleElement.h \
unicode.h \
--- /dev/null
+/*\r
+ * Copyright 2001-2006 Internet2\r
+ * \r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+/**\r
+ * @file PluginManager.h\r
+ * \r
+ * Plugin management template\r
+ */\r
+\r
+#ifndef __xmltooling_plugin_h__\r
+#define __xmltooling_plugin_h__\r
+\r
+#include <xmltooling/base.h>\r
+\r
+#include <map>\r
+#include <string>\r
+#include <xercesc/dom/DOM.hpp>\r
+\r
+using namespace xercesc;\r
+\r
+namespace xmltooling {\r
+\r
+ /**\r
+ * Template for management/access to plugins constructed based on a string type\r
+ * and arbitrary parameters.\r
+ * \r
+ * @param T class of plugin to manage\r
+ * @param Params parameters for plugin construction\r
+ */\r
+ template <class T, typename Params> class XMLTOOL_API PluginManager\r
+ {\r
+ public:\r
+ PluginManager() {}\r
+ ~PluginManager() {}\r
+\r
+ /** Factory function for plugin. */\r
+ typedef T* Factory(typename Params&);\r
+\r
+ /**\r
+ * Registers the factory for a given type.\r
+ * \r
+ * @param type the name of the plugin type\r
+ * @param factory the factory function for the plugin type\r
+ */\r
+ void registerFactory(const char* type, typename Factory* factory) {\r
+ if (type && factory)\r
+ m_map[type]=factory;\r
+ }\r
+\r
+ /**\r
+ * Unregisters the factory for a given type.\r
+ * \r
+ * @param type the name of the plugin type\r
+ */\r
+ void deregisterFactory(const char* type) {\r
+ if (type) {\r
+ m_map.erase(type);\r
+ }\r
+ }\r
+\r
+ /**\r
+ * Builds a new instance of a plugin of a given type, configuring it\r
+ * with the supplied element, if any.\r
+ * \r
+ * @param type the name of the plugin type\r
+ * @param p parameters to configure plugin\r
+ * @return the constructed plugin \r
+ */\r
+ T* newPlugin(const char* type, typename Params& p) {\r
+ std::map<std::string, typename Factory*>::const_iterator i=m_map.find(type);\r
+ if (i==m_map.end())\r
+ throw UnknownExtensionException("Unable to build plugin of type '$1'",params(1,type));\r
+ return i->second(p);\r
+ }\r
+ \r
+ private:\r
+ std::map<std::string, typename Factory*> m_map;\r
+ };\r
+\r
+};\r
+\r
+#endif /* __xmltooling_plugin_h__ */\r
DECL_EXCEPTION_FACTORY(UnmarshallingException,xmltooling);
DECL_EXCEPTION_FACTORY(UnknownElementException,xmltooling);
DECL_EXCEPTION_FACTORY(UnknownAttributeException,xmltooling);
+DECL_EXCEPTION_FACTORY(UnknownExtensionException,xmltooling);
DECL_EXCEPTION_FACTORY(ValidationException,xmltooling);
#ifndef XMLTOOLING_NO_XMLSEC
Category::getInstance(XMLTOOLING_LOGCAT".XMLToolingConfig").info("library shutdown complete");
}
-ILockable& XMLToolingInternalConfig::lock()
+Lockable& XMLToolingInternalConfig::lock()
{
xercesc::XMLPlatformUtils::lockMutex(m_lock);
return *this;
* Library configuration \r
*/\r
\r
-#if !defined(__xmltooling_config_h__)\r
+#ifndef __xmltooling_config_h__\r
#define __xmltooling_config_h__\r
\r
-#include <xmltooling/ILockable.h>\r
+#include <xmltooling/Lockable.h>\r
\r
namespace xmltooling {\r
\r
* obtain a global system lock, but the actual configuration itself is not\r
* synchronized.\r
*/\r
- class XMLTOOL_API XMLToolingConfig : public ILockable\r
+ class XMLTOOL_API XMLToolingConfig : public Lockable\r
{\r
MAKE_NONCOPYABLE(XMLToolingConfig);\r
public:\r
DECL_XMLTOOLING_EXCEPTION(UnmarshallingException,xmltooling,XMLToolingException,Exceptions during object unmarshalling);
DECL_XMLTOOLING_EXCEPTION(UnknownElementException,xmltooling,XMLToolingException,Exceptions due to processing of unknown element content);
DECL_XMLTOOLING_EXCEPTION(UnknownAttributeException,xmltooling,XMLToolingException,Exceptions due to processing of unknown attributes);
+ DECL_XMLTOOLING_EXCEPTION(UnknownExtensionException,xmltooling,XMLToolingException,Exceptions from use of an unrecognized extension/plugin);
DECL_XMLTOOLING_EXCEPTION(ValidationException,xmltooling,XMLToolingException,Exceptions during object validation);
};
# define _CRT_NONSTDC_NO_DEPRECATE 1
#endif
+// Export public APIs.
+#define XMLTOOLING_EXPORTS
+
// eventually we might be able to support autoconf via cygwin...
#if defined (_MSC_VER) || defined(__BORLANDC__)
# include "config_win32.h"
void term();
// global mutex available to library applications
- xmltooling::ILockable& lock();
+ Lockable& lock();
void unlock();
// configuration
private:
std::vector<void*> m_libhandles;
void* m_lock;
- //PlugManager m_plugMgr;
};
/// @endcond
Name="VCCLCompilerTool"\r
Optimization="0"\r
AdditionalIncludeDirectories=""$(SolutionDir)";"$(ProjectDir)""\r
- PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;XMLTOOLING_EXPORTS"\r
+ PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL"\r
MinimalRebuild="true"\r
BasicRuntimeChecks="3"\r
RuntimeLibrary="3"\r
<Tool\r
Name="VCCLCompilerTool"\r
AdditionalIncludeDirectories=""$(SolutionDir)";"$(ProjectDir)""\r
- PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;XMLTOOLING_EXPORTS"\r
+ PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL"\r
RuntimeLibrary="2"\r
UsePrecompiledHeader="0"\r
WarningLevel="3"\r
>\r
</File>\r
<File\r
- RelativePath=".\ILockable.h"\r
+ RelativePath=".\internal.h"\r
>\r
</File>\r
<File\r
- RelativePath=".\internal.h"\r
+ RelativePath=".\Lockable.h"\r
>\r
</File>\r
<File\r
>\r
</File>\r
<File\r
+ RelativePath=".\PluginManager.h"\r
+ >\r
+ </File>\r
+ <File\r
RelativePath=".\QName.h"\r
>\r
</File>\r