123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179 |
- /*=============================================================================
- Library: CTK
- Copyright (c) 2010 Brigham and Women's Hospital (BWH) All Rights Reserved.
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use d 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 "ctkCmdLineModuleDescription.h"
- #include "ctkCmdLineModuleDescription_p.h"
- #include "ctkCmdLineModuleParameter.h"
- #include "ctkCmdLineModuleParameterGroup.h"
- #include "ctkException.h"
- #include <QTextStream>
- //----------------------------------------------------------------------------
- ctkCmdLineModuleDescription::ctkCmdLineModuleDescription()
- : d(new ctkCmdLineModuleDescriptionPrivate())
- {
- }
- //----------------------------------------------------------------------------
- ctkCmdLineModuleDescription::ctkCmdLineModuleDescription(const ctkCmdLineModuleDescription &description)
- : d(description.d)
- {
- }
- //----------------------------------------------------------------------------
- ctkCmdLineModuleDescription::~ctkCmdLineModuleDescription()
- {
- }
- //----------------------------------------------------------------------------
- ctkCmdLineModuleDescription &ctkCmdLineModuleDescription::operator =(const ctkCmdLineModuleDescription &other)
- {
- d = other.d;
- return *this;
- }
- //----------------------------------------------------------------------------
- QString ctkCmdLineModuleDescription::category() const
- {
- return d->Category;
- }
- //----------------------------------------------------------------------------
- QString ctkCmdLineModuleDescription::title() const
- {
- return d->Title;
- }
- //----------------------------------------------------------------------------
- QString ctkCmdLineModuleDescription::categoryDotTitle() const
- {
- return this->category() + "." + this->title();
- }
- //----------------------------------------------------------------------------
- QString ctkCmdLineModuleDescription::description() const
- {
- return d->Description;
- }
- //----------------------------------------------------------------------------
- QString ctkCmdLineModuleDescription::version() const
- {
- return d->Version;
- }
- //----------------------------------------------------------------------------
- QString ctkCmdLineModuleDescription::documentationURL() const
- {
- return d->DocumentationURL;
- }
- //----------------------------------------------------------------------------
- QString ctkCmdLineModuleDescription::license() const
- {
- return d->License;
- }
- //----------------------------------------------------------------------------
- QString ctkCmdLineModuleDescription::acknowledgements() const
- {
- return d->Acknowledgements;
- }
- //----------------------------------------------------------------------------
- QString ctkCmdLineModuleDescription::contributor() const
- {
- return d->Contributor;
- }
- //----------------------------------------------------------------------------
- QIcon ctkCmdLineModuleDescription::logo() const
- {
- return d->Logo;
- }
- //----------------------------------------------------------------------------
- QList<ctkCmdLineModuleParameterGroup> ctkCmdLineModuleDescription::parameterGroups() const
- {
- return d->ParameterGroups;
- }
- //----------------------------------------------------------------------------
- bool ctkCmdLineModuleDescription::hasParameter(const QString& name) const
- {
- // iterate over each parameter group
- foreach(const ctkCmdLineModuleParameterGroup group, d->ParameterGroups)
- {
- if (group.hasParameter(name)) return true;
- }
- return false;
- }
- //----------------------------------------------------------------------------
- ctkCmdLineModuleParameter ctkCmdLineModuleDescription::parameter(const QString& name) const
- {
- foreach(const ctkCmdLineModuleParameterGroup group, d->ParameterGroups)
- {
- if (group.hasParameter(name))
- {
- return group.parameter(name);
- }
- }
- throw ctkInvalidArgumentException(QString("No parameter named \"%1\" available.").arg(name));
- }
- //----------------------------------------------------------------------------
- bool ctkCmdLineModuleDescription::hasReturnParameters() const
- {
- // iterate over each parameter group
- foreach(const ctkCmdLineModuleParameterGroup group, d->ParameterGroups)
- {
- if (group.hasReturnParameters()) return true;
- }
- return false;
- }
- //----------------------------------------------------------------------------
- QTextStream & operator<<(QTextStream &os, const ctkCmdLineModuleDescription &module)
- {
- os << "Title: " << module.title() << '\n';
- os << "Category: " << module.category() << '\n';
- os << "Description: " << module.description() << '\n';
- os << "Version: " << module.version() << '\n';
- os << "DocumentationURL: " << module.documentationURL() << '\n';
- os << "License: " << module.license() << '\n';
- os << "Contributor: " << module.contributor() << '\n';
- os << "Acknowledgements: " << module.acknowledgements() << '\n';
- //os << "Logo: " << module.GetLogo() << '\n';
- os << "ParameterGroups: " << '\n';
- foreach(const ctkCmdLineModuleParameterGroup group, module.parameterGroups())
- {
- os << group;
- }
- return os;
- }
|