123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129 |
- /*=============================================================================
- Library: CTK
- Copyright (c) German Cancer Research Center,
- Division of Medical and Biological Informatics
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
- http://www.apache.org/licenses/LICENSE-2.0
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
- =============================================================================*/
- #include "ctkPluginEvent.h"
- #include "ctkPlugin.h"
- #include <QDebug>
- class ctkPluginEventData : public QSharedData
- {
- public:
- ctkPluginEventData(ctkPluginEvent::Type type, QSharedPointer<ctkPlugin> plugin)
- : type(type), plugin(plugin)
- {
- }
- ctkPluginEventData(const ctkPluginEventData& other)
- : QSharedData(other), type(other.type), plugin(other.plugin)
- {
- }
- const ctkPluginEvent::Type type;
- const QSharedPointer<ctkPlugin> plugin;
- };
- //----------------------------------------------------------------------------
- ctkPluginEvent::ctkPluginEvent()
- : d(0)
- {
- }
- //----------------------------------------------------------------------------
- ctkPluginEvent::~ctkPluginEvent()
- {
- }
- //----------------------------------------------------------------------------
- bool ctkPluginEvent::isNull() const
- {
- return !d;
- }
- //----------------------------------------------------------------------------
- ctkPluginEvent::ctkPluginEvent(Type type, QSharedPointer<ctkPlugin> plugin)
- : d(new ctkPluginEventData(type, plugin))
- {
- }
- //----------------------------------------------------------------------------
- ctkPluginEvent::ctkPluginEvent(const ctkPluginEvent& other)
- : d(other.d)
- {
- }
- //----------------------------------------------------------------------------
- ctkPluginEvent& ctkPluginEvent::operator=(const ctkPluginEvent& other)
- {
- d = other.d;
- return *this;
- }
- //----------------------------------------------------------------------------
- QSharedPointer<ctkPlugin> ctkPluginEvent::getPlugin() const
- {
- return d->plugin;
- }
- //----------------------------------------------------------------------------
- ctkPluginEvent::Type ctkPluginEvent::getType() const
- {
- return d->type;
- }
- //----------------------------------------------------------------------------
- QDebug operator<<(QDebug debug, ctkPluginEvent::Type eventType)
- {
- switch (eventType)
- {
- case ctkPluginEvent::INSTALLED: return debug << "INSTALLED";
- case ctkPluginEvent::STARTED: return debug << "STARTED";
- case ctkPluginEvent::STOPPED: return debug << "STOPPED";
- case ctkPluginEvent::UPDATED: return debug << "UPDATED";
- case ctkPluginEvent::UNINSTALLED: return debug << "UNINSTALLED";
- case ctkPluginEvent::RESOLVED: return debug << "RESOLVED";
- case ctkPluginEvent::UNRESOLVED: return debug << "UNRESOLVED";
- case ctkPluginEvent::STARTING: return debug << "STARTING";
- case ctkPluginEvent::STOPPING: return debug << "STOPPING";
- case ctkPluginEvent::LAZY_ACTIVATION: return debug << "LAZY_ACTIVATION";
- default: return debug << "Unknown plugin event type (" << static_cast<int>(eventType) << ")";
- }
- }
- //----------------------------------------------------------------------------
- QDebug operator<<(QDebug debug, const ctkPluginEvent& event)
- {
- if (event.isNull()) return debug << "NONE";
- QSharedPointer<ctkPlugin> p = event.getPlugin();
- debug.nospace() << event.getType() << " #" << p->getPluginId() << " (" << p->getLocation() << ")";
- return debug.maybeSpace();
- }
|