Commit c4e53b3e authored by T.J. Corona's avatar T.J. Corona
Browse files

Add logic for registering managers

parent 29b81101
......@@ -81,6 +81,5 @@ function (smtk_add_plugin name)
${_smtk_plugin_PARAVIEW_PLUGIN_ARGS})
target_link_libraries("${_smtk_plugin_name}"
PRIVATE
smtkCore
smtkPluginSupport)
smtkCore)
endfunction ()
......@@ -12,15 +12,15 @@
#include "@_smtk_plugin_REGISTRAR_HEADER@"
#include "smtk/extension/paraview/pluginsupport/PluginClient.txx"
#include "smtk/plugin/Client.txx"
#include "vtkNew.h"
#include "vtkPVPluginLoader.h"
#include <memory>
typedef smtk::extension::paraview::PluginClient<
@_smtk_plugin_REGISTRAR@, @_smtk_plugin_managers@> @_smtk_plugin_name@Client;
typedef smtk::plugin::Client<@_smtk_plugin_REGISTRAR@, @_smtk_plugin_managers@>
@_smtk_plugin_name@Client;
static std::shared_ptr<@_smtk_plugin_name@Client> my@_smtk_plugin_name@Client =
std::dynamic_pointer_cast<@_smtk_plugin_name@Client>(@_smtk_plugin_name@Client::create());
......@@ -23,7 +23,7 @@
#include "smtk/session/polygon/Registrar.h"
#include "smtk/common/Registry.h"
#include "smtk/plugin/Registry.h"
int main(int argc, char* argv[])
{
......@@ -46,7 +46,7 @@ int main(int argc, char* argv[])
char* filename = argv[2];
auto rsrcMgr = smtk::resource::Manager::create();
auto operMgr = smtk::operation::Manager::create();
auto polygonRegistry = smtk::common::Registry<smtk::session::polygon::Registrar,
auto polygonRegistry = smtk::plugin::Registry<smtk::session::polygon::Registrar,
smtk::resource::Manager, smtk::operation::Manager>(rsrcMgr, operMgr);
auto rdr = operMgr->create<smtk::operation::ReadResource>();
......
# Changes to SMTK Plugins
SMTK's plugin system now facilitates the registration of new managers in addition to registering
things to existing managers.
......@@ -698,7 +698,6 @@ INPUT = \
"@smtk_SOURCE_DIR@/smtk/extension/paraview/appcomponents/resources" \
"@smtk_SOURCE_DIR@/smtk/extension/paraview/appcomponents/plugin" \
"@smtk_SOURCE_DIR@/smtk/extension/paraview/appcomponents/plugin/resources" \
"@smtk_SOURCE_DIR@/smtk/extension/paraview/pluginsupport" \
"@smtk_SOURCE_DIR@/smtk/extension/paraview/widgets" \
"@smtk_SOURCE_DIR@/smtk/extension/paraview/widgets/plugin" \
"@smtk_SOURCE_DIR@/smtk/extension/paraview/widgets/plugin/resources" \
......@@ -805,7 +804,6 @@ INPUT = \
"@smtk_BINARY_DIR@/smtk/extension/paraview/appcomponents/resources" \
"@smtk_BINARY_DIR@/smtk/extension/paraview/appcomponents/plugin" \
"@smtk_BINARY_DIR@/smtk/extension/paraview/appcomponents/plugin/resources" \
"@smtk_BINARY_DIR@/smtk/extension/paraview/pluginsupport" \
"@smtk_BINARY_DIR@/smtk/extension/paraview/widgets" \
"@smtk_BINARY_DIR@/smtk/extension/paraview/widgets/plugin" \
"@smtk_BINARY_DIR@/smtk/extension/paraview/widgets/plugin/resources" \
......
Plugins
========
SMTK plugins are extensions of ParaView plugins that allow for the automatic
registration of components to SMTK managers. They are created using the
CMake function "add_smtk_plugin", which requires the developer to explicitly list
SMTK plugins are extensions of ParaView plugins that allow for the
definition of SMTK managers and the automatic registration of
components to these managers. They are created using the CMake
function "add_smtk_plugin", which requires the developer to explicitly list
a registration class "known as a Registrar" and a list of SMTK manager types
to which the plugin registers. SMTK plugins can be introduced to a
ParaView-based application in several ways. The consuming project can
......@@ -28,3 +29,9 @@ plugin targets (which can be a part of the project or imported from another
project) described by the global property "SMTK_PLUGINS" to generate a library
against which the application can link to directly incorporate the associated
plugins.
Managers are introduced to SMTK by registering them with the instance
of `smtk::common::Managers`. Upon registration, the singleton instance
of `smtk::plugin::Manager` can be used to register additional plugins
to the newly created manager. See `smtk/resource/Registrar.cxx` for an
example of introducing a manager.
......@@ -42,6 +42,9 @@ smtk_source_group(view)
add_subdirectory(workflow)
smtk_source_group(workflow)
add_subdirectory(plugin)
smtk_source_group(plugin)
set(smtk_headers
${commonHeaders}
${resourceHeaders}
......@@ -54,6 +57,7 @@ set(smtk_headers
${projectHeaders}
${viewHeaders}
${workflowHeaders}
${pluginHeaders}
${simulationHeaders}
${ioHeaders}
)
......@@ -69,6 +73,7 @@ set(smtk_srcs
${modelSrcs}
${viewSrcs}
${workflowSrcs}
${pluginSrcs}
${simulationSrcs}
${ioSrcs}
)
......@@ -240,5 +245,21 @@ add_subdirectory(session)
# single library for initializing them in a ParaView-derived application.
################################################################################
if (SMTK_ENABLE_PARAVIEW_SUPPORT)
add_subdirectory(plugin)
get_property(smtk_paraview_plugin_files GLOBAL
PROPERTY _smtk_plugin_files)
paraview_plugin_scan(
PLUGIN_FILES ${smtk_paraview_plugin_files}
PROVIDES_PLUGINS paraview_plugins
ENABLE_BY_DEFAULT ON
HIDE_PLUGINS_FROM_CACHE ON)
paraview_plugin_build(
HEADERS_DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}/${PROJECT_VERSION}"
LIBRARY_SUBDIRECTORY "${PROJECT_NAME}-${PROJECT_VERSION}"
PLUGINS ${paraview_plugins}
PLUGINS_FILE_NAME "smtk.paraview.xml"
AUTOLOAD ${paraview_plugins}
INSTALL_EXPORT SMTKParaViewPlugins
CMAKE_DESTINATION ${SMTK_INSTALL_CONFIG_DIR}
ADD_INSTALL_RPATHS ON
TARGET smtk_paraview_plugins)
endif()
......@@ -25,7 +25,7 @@
#include "smtk/session/polygon/Registrar.h"
#include "smtk/common/Registry.h"
#include "smtk/plugin/Registry.h"
#include "smtk/io/Logger.h"
......@@ -59,11 +59,11 @@ int unitDetachReferenceItem(int argc, char* argv[])
auto operationManager = smtk::operation::Manager::create();
operationManager->registerResourceManager(resourceManager);
auto attributeRegistry = smtk::common::Registry<smtk::attribute::Registrar,
auto attributeRegistry = smtk::plugin::Registry<smtk::attribute::Registrar,
smtk::resource::Manager, smtk::operation::Manager>(resourceManager, operationManager);
auto operationRegistry = smtk::common::Registry<smtk::operation::Registrar,
auto operationRegistry = smtk::plugin::Registry<smtk::operation::Registrar,
smtk::resource::Manager, smtk::operation::Manager>(resourceManager, operationManager);
auto polygonRegistry = smtk::common::Registry<smtk::session::polygon::Registrar,
auto polygonRegistry = smtk::plugin::Registry<smtk::session::polygon::Registrar,
smtk::resource::Manager, smtk::operation::Manager>(resourceManager, operationManager);
for (int i = 1; i < argc; i++)
......
......@@ -35,7 +35,7 @@
#include "smtk/session/polygon/Registrar.h"
#include "smtk/common/Registry.h"
#include "smtk/plugin/Registry.h"
#include "smtk/io/Logger.h"
......@@ -74,11 +74,11 @@ int unitJsonItems(int argc, char* argv[])
auto operMgr = smtk::operation::Manager::create();
operMgr->registerResourceManager(rsrcMgr);
auto attRegistry = smtk::common::Registry<smtk::attribute::Registrar, smtk::resource::Manager,
auto attRegistry = smtk::plugin::Registry<smtk::attribute::Registrar, smtk::resource::Manager,
smtk::operation::Manager>(rsrcMgr, operMgr);
auto opRegistry = smtk::common::Registry<smtk::operation::Registrar, smtk::resource::Manager,
auto opRegistry = smtk::plugin::Registry<smtk::operation::Registrar, smtk::resource::Manager,
smtk::operation::Manager>(rsrcMgr, operMgr);
auto polyRegistry = smtk::common::Registry<smtk::session::polygon::Registrar,
auto polyRegistry = smtk::plugin::Registry<smtk::session::polygon::Registrar,
smtk::resource::Manager, smtk::operation::Manager>(rsrcMgr, operMgr);
smtk::resource::ResourceArray rsrcs;
......
......@@ -26,7 +26,7 @@
#include "smtk/session/polygon/Registrar.h"
#include "smtk/common/Registry.h"
#include "smtk/plugin/Registry.h"
#include "smtk/io/Logger.h"
......@@ -60,11 +60,11 @@ int unitUnsetValueError(int argc, char* argv[])
auto operationManager = smtk::operation::Manager::create();
operationManager->registerResourceManager(resourceManager);
auto attributeRegistry = smtk::common::Registry<smtk::attribute::Registrar,
auto attributeRegistry = smtk::plugin::Registry<smtk::attribute::Registrar,
smtk::resource::Manager, smtk::operation::Manager>(resourceManager, operationManager);
auto operationRegistry = smtk::common::Registry<smtk::operation::Registrar,
auto operationRegistry = smtk::plugin::Registry<smtk::operation::Registrar,
smtk::resource::Manager, smtk::operation::Manager>(resourceManager, operationManager);
auto polygonRegistry = smtk::common::Registry<smtk::session::polygon::Registrar,
auto polygonRegistry = smtk::plugin::Registry<smtk::session::polygon::Registrar,
smtk::resource::Manager, smtk::operation::Manager>(resourceManager, operationManager);
for (int i = 1; i < argc; i++)
......
......@@ -9,8 +9,8 @@ set(commonSrcs
FileLocation.cxx
json/jsonLinks.cxx
json/jsonUUID.cxx
Managers.cxx
Paths.cxx
Registry.cxx
StringUtil.cxx
TimeZone.cxx
timezonespec.cxx
......@@ -35,10 +35,10 @@ set(commonHeaders
json/jsonTypeMap.h
json/jsonUUID.h
Links.h
Managers.h
Observers.h
Paths.h
RangeDetector.h
Registry.h
Singleton.h
StringUtil.h
ThreadPool.h
......
//=========================================================================
// Copyright (c) Kitware, Inc.
// All rights reserved.
// See LICENSE.txt for details.
//
// This software is distributed WITHOUT ANY WARRANTY; without even
// the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
// PURPOSE. See the above copyright notice for more information.
//=========================================================================
#include "smtk/common/Managers.h"
namespace smtk
{
namespace common
{
Managers::Managers() = default;
Managers::~Managers() = default;
}
}
......@@ -8,29 +8,31 @@
// PURPOSE. See the above copyright notice for more information.
//=========================================================================
#ifndef __smtk_extension_paraview_pluginsupport_PluginClient_txx
#define __smtk_extension_paraview_pluginsupport_PluginClient_txx
#ifndef __smtk_common_Managers_h
#define __smtk_common_Managers_h
#include "smtk/extension/paraview/pluginsupport/PluginClient.h"
#include "smtk/extension/paraview/pluginsupport/PluginClientBase.h"
#include "smtk/extension/paraview/pluginsupport/PluginManager.h"
#include "smtk/CoreExports.h"
#include "smtk/SharedFromThis.h"
#include "smtk/common/TypeContainer.h"
namespace smtk
{
namespace extension
{
namespace paraview
namespace common
{
template <typename Registrar, typename Manager, typename... T>
std::shared_ptr<PluginClientBase> PluginClient<Registrar, Manager, T...>::create()
class SMTKCORE_EXPORT Managers : public TypeContainer, public std::enable_shared_from_this<Managers>
{
std::shared_ptr<PluginClient<Registrar, Manager, T...> > shared(
new PluginClient<Registrar, Manager, T...>);
smtk::extension::paraview::PluginManager::instance()->addPluginClient(
std::static_pointer_cast<PluginClientBase>(shared->PluginClientBase::shared_from_this()));
return std::static_pointer_cast<PluginClientBase>(shared);
}
}
public:
typedef TypeContainer Container;
smtkTypeMacroBase(smtk::common::Managers);
smtkCreateMacro(Managers);
virtual ~Managers();
protected:
Managers();
};
}
}
......
......@@ -181,6 +181,12 @@ public:
return *(static_cast<WrapperFor<Type>*>(search->second.get()))->value;
}
template <typename Type>
bool erase()
{
return m_container.erase(typeid(Type).hash_code()) > 0;
}
bool empty() const noexcept { return m_container.empty(); }
std::size_t size() const noexcept { return m_container.size(); }
......
......@@ -38,7 +38,6 @@ set(unit_tests
UnitTestFactory
UnitTestLinks
UnitTestObservers
UnitTestRegistry.cxx
UnitTestThreadPool
UnitTestTypeContainer
UnitTestTypeMap
......
################################################################################
# Build widgets
################################################################################
add_subdirectory(pluginsupport)
set(module_files
"${CMAKE_CURRENT_SOURCE_DIR}/appcomponents/vtk.module"
"${CMAKE_CURRENT_SOURCE_DIR}/mesh/vtk.module"
......
......@@ -12,6 +12,8 @@
#ifndef __VTK_WRAP__
#include "smtk/extension/paraview/appcomponents/smtkPQComponentsExtModule.h"
#include "smtk/common/Managers.h"
#include "smtk/view/Manager.h"
namespace smtk
......
......@@ -137,9 +137,9 @@ smtk_add_plugin(smtkPQComponentsPlugin
smtk::extension::paraview::server::Registrar
smtk::extension::paraview::appcomponents::Registrar
MANAGERS
smtk::geometry::Manager
smtk::operation::Manager
smtk::resource::Manager
smtk::geometry::Manager
smtk::view::Manager
PARAVIEW_PLUGIN_ARGS
VERSION "1.0"
......
......@@ -23,7 +23,6 @@ vtk_module_add_module(smtkPVMeshExt
vtk_module_link(smtkPVMeshExt
PUBLIC
nlohmann_json
smtkPluginSupport
vtkSMTKMeshExt
)
......
......@@ -12,12 +12,20 @@ smtk_add_client_tests(
# LABEL "pv_meshsession"
TEST_SCRIPTS ${TESTS_WITH_BASELINES}
LOAD_PLUGINS
smtkResourcePlugin
smtkOperationPlugin
smtkGeometryPlugin
smtkViewPlugin
smtkMeshPlugin
smtkQtPlugin
smtkPVServerExtPlugin
smtkPQComponentsPlugin
smtkPVMeshExtPlugin
PLUGIN_PATHS
$<TARGET_FILE_DIR:smtkResourcePlugin>/..
$<TARGET_FILE_DIR:smtkOperationPlugin>/..
$<TARGET_FILE_DIR:smtkGeometryPlugin>/..
$<TARGET_FILE_DIR:smtkViewPlugin>/..
$<TARGET_FILE_DIR:smtkMeshPlugin>/..
$<TARGET_FILE_DIR:smtkQtPlugin>/..
$<TARGET_FILE_DIR:smtkPVMeshExtPlugin>/..
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment