Medical Imaging Interaction Toolkit  2023.12.99-63768887
Medical Imaging Interaction Toolkit
berry::ParameterizedCommand Class Reference

#include <berryParameterizedCommand.h>

Inheritance diagram for berry::ParameterizedCommand:
Collaboration diagram for berry::ParameterizedCommand:

Public Member Functions

 berryObjectMacro (ParameterizedCommand)
 
 ParameterizedCommand (const SmartPointer< Command > &command, const QList< Parameterization > &parameterizations)
 
bool operator< (const Object *object) const override
 
bool operator== (const Object *object) const override
 
Object::Pointer ExecuteWithChecks (const Object::ConstPointer &trigger, const Object::Pointer &applicationContext)
 
SmartPointer< CommandGetCommand () const
 
QString GetId () const
 
QString GetName () const
 
QHash< QString, QString > GetParameterMap () const
 
uint HashCode () const override
 
QString Serialize ()
 
QString ToString () const override
 
- Public Member Functions inherited from berry::Object
virtual QString GetClassName () const
 
virtual Reflection::TypeInfo GetTypeInfo () const
 
virtual QList< Reflection::TypeInfoGetSuperclasses () const
 
virtual void Delete ()
 
QDebug Print (QDebug os, Indent Indent=0) const
 
void Register () const
 
void UnRegister (bool del=true) const
 
int GetReferenceCount () const
 
void SetReferenceCount (int)
 
void AddDestroyListener (const MessageAbstractDelegate<> &delegate) const
 
void RemoveDestroyListener (const MessageAbstractDelegate<> &delegate) const
 

Static Public Member Functions

static QList< ParameterizedCommand::PointerGenerateCombinations (const SmartPointer< Command > command)
 
static ParameterizedCommand::Pointer GenerateCommand (const SmartPointer< Command > command, const QHash< QString, Object::Pointer > &parameters)
 
- Static Public Member Functions inherited from berry::Object
static const char * GetStaticClassName ()
 
static Reflection::TypeInfo GetStaticTypeInfo ()
 
static QList< Reflection::TypeInfoGetStaticSuperclasses ()
 

Static Public Attributes

static const int INDEX_PARAMETER_ID
 
static const int INDEX_PARAMETER_NAME
 
static const int INDEX_PARAMETER_VALUE_NAME
 
static const int INDEX_PARAMETER_VALUE_VALUE
 

Additional Inherited Members

- Public Types inherited from berry::Object
typedef Object Self
 
typedef berry::SmartPointer< SelfPointer
 
typedef berry::SmartPointer< const SelfConstPointer
 
typedef berry::WeakPointer< SelfWeakPtr
 
typedef berry::WeakPointer< const SelfConstWeakPtr
 
- Protected Member Functions inherited from berry::Object
 Object ()
 
virtual ~Object ()
 
virtual QDebug PrintSelf (QDebug os, Indent indent) const
 
virtual QDebug PrintHeader (QDebug os, Indent indent) const
 
virtual QDebug PrintTrailer (QDebug os, Indent indent) const
 
- Protected Attributes inherited from berry::Object
QAtomicInt m_ReferenceCount
 
QMutex m_ReferenceCountLock
 

Detailed Description

A command that has had one or more of its parameters specified. This class serves as a utility class for developers that need to manipulate commands with parameters. It handles the behaviour of generating a parameter map and a human-readable name.

Definition at line 40 of file berryParameterizedCommand.h.

Constructor & Destructor Documentation

◆ ParameterizedCommand()

berry::ParameterizedCommand::ParameterizedCommand ( const SmartPointer< Command > &  command,
const QList< Parameterization > &  parameterizations 
)

Constructs a new instance of ParameterizedCommand with specific values for zero or more of its parameters.

Parameters
commandThe command that is parameterized; must not be null.
parameterizationsAn array of parameterizations binding parameters to values for the command. This value may be null.

Member Function Documentation

◆ berryObjectMacro()

berry::ParameterizedCommand::berryObjectMacro ( ParameterizedCommand  )

◆ ExecuteWithChecks()

Object::Pointer berry::ParameterizedCommand::ExecuteWithChecks ( const Object::ConstPointer trigger,
const Object::Pointer applicationContext 
)

Executes this command with its parameters. This does extra checking to see if the command is enabled and defined. If it is not both enabled and defined, then the execution listeners will be notified and an exception thrown.

Parameters
triggerThe object that triggered the execution; may be null.
applicationContextThe state of the application at the time the execution was triggered; may be null.
Returns
The result of the execution; may be null.
Exceptions
ExecutionExceptionIf the handler has problems executing this command.
NotDefinedExceptionIf the command you are trying to execute is not defined.
NotEnabledExceptionIf the command you are trying to execute is not enabled.
NotHandledExceptionIf there is no handler.

◆ GenerateCombinations()

static QList<ParameterizedCommand::Pointer> berry::ParameterizedCommand::GenerateCombinations ( const SmartPointer< Command command)
static

Generates all the possible combinations of command parameterizations for the given command. If the command has no parameters, then this is simply a parameterized version of that command. If a parameter is optional, both the included and not included cases are considered.

If one of the parameters cannot be loaded due to a ParameterValuesException, then it is simply ignored.

Parameters
commandThe command for which the parameter combinations should be generated; must not be null.
Returns
A collection of ParameterizedCommand instances representing all of the possible combinations. This value is never empty and it is never null.
Exceptions
NotDefinedExceptionIf the command is not defined.

◆ GenerateCommand()

static ParameterizedCommand::Pointer berry::ParameterizedCommand::GenerateCommand ( const SmartPointer< Command command,
const QHash< QString, Object::Pointer > &  parameters 
)
static

Take a command and a map of parameter IDs to values, and generate the appropriate parameterized command.

Parameters
commandThe command object. Must not be null.
parametersA map of String parameter ids to objects. May be null.
Returns
the parameterized command, or null if it could not be generated

◆ GetCommand()

SmartPointer<Command> berry::ParameterizedCommand::GetCommand ( ) const

Returns the base command. It is possible for more than one parameterized command to have the same identifier.

Returns
The command; never null, but may be undefined.

◆ GetId()

QString berry::ParameterizedCommand::GetId ( ) const

Returns the command's base identifier. It is possible for more than one parameterized command to have the same identifier.

Returns
The command id; never null.

◆ GetName()

QString berry::ParameterizedCommand::GetName ( ) const

Returns a human-readable representation of this command with all of its parameterizations.

Returns
The human-readable representation of this parameterized command; never null.
Exceptions
NotDefinedExceptionIf the underlying command is not defined.

◆ GetParameterMap()

QHash<QString, QString> berry::ParameterizedCommand::GetParameterMap ( ) const

Returns the parameter map, as can be used to construct an ExecutionEvent.

Returns
The map of parameter ids (String) to parameter values (String). This map is never null, but may be empty.

◆ HashCode()

uint berry::ParameterizedCommand::HashCode ( ) const
overridevirtual

Returns a hash code value for the object.

Reimplemented from berry::Object.

◆ operator<()

bool berry::ParameterizedCommand::operator< ( const Object ) const
overridevirtual

Override this method to implement a specific "less than" operator for associative STL containers.

Reimplemented from berry::Object.

◆ operator==()

bool berry::ParameterizedCommand::operator== ( const Object ) const
overridevirtual

A generic comparison method. Override this method in subclasses and cast to your derived class to provide a more detailed comparison.

Reimplemented from berry::Object.

◆ Serialize()

QString berry::ParameterizedCommand::Serialize ( )

Returns a String containing the command id, parameter ids and parameter values for this ParameterizedCommand . The returned String can be stored by a client and later used to reconstruct an equivalent ParameterizedCommand using the CommandManager.deserialize(String) method.

The syntax of the returned String is as follows:

serialization = commandId [ '(' parameters ')' ]
parameters = parameter [ ',' parameters ]
parameter = parameterId [ '=' parameterValue ]

In the syntax above, sections inside square-brackets are optional. The characters in single quotes ((, ), , and =) indicate literal characters.

commandId represents the command id encoded with separator characters escaped. parameterId and parameterValue represent the parameter ids and values encoded with separator characters escaped. The separator characters (, ), , and = are escaped by prepending a %. This requires % to be escaped, which is also done by prepending a %.

The order of the parameters is not defined (and not important). A missing parameterValue indicates that the value of the parameter is null.

For example, the string shown below represents a serialized parameterized command that can be used to show the Resource perspective:

org.eclipse.ui.perspectives.showPerspective(org.eclipse.ui.perspectives.showPerspective.perspectiveId=org.eclipse.ui.resourcePerspective)

This example shows the more general form with multiple parameters, null value parameters, and escaped = in the third parameter value.

command.id(param1.id=value1,param2.id,param3.id=esc%=val3)

Returns
A string containing the escaped command id, parameter ids and parameter values; never null.
See also
CommandManager::deserialize(String)

◆ ToString()

QString berry::ParameterizedCommand::ToString ( ) const
overridevirtual

Returns a string representation of this object. The default implementation returns an empty string.

Reimplemented from berry::Object.

Member Data Documentation

◆ INDEX_PARAMETER_ID

const int berry::ParameterizedCommand::INDEX_PARAMETER_ID
static

The index of the parameter id in the parameter values.

Deprecated:
no longer used

Definition at line 52 of file berryParameterizedCommand.h.

◆ INDEX_PARAMETER_NAME

const int berry::ParameterizedCommand::INDEX_PARAMETER_NAME
static

The index of the human-readable name of the parameter itself, in the parameter values.

Deprecated:
no longer used

Definition at line 60 of file berryParameterizedCommand.h.

◆ INDEX_PARAMETER_VALUE_NAME

const int berry::ParameterizedCommand::INDEX_PARAMETER_VALUE_NAME
static

The index of the human-readable name of the value of the parameter for this command.

Deprecated:
no longer used

Definition at line 68 of file berryParameterizedCommand.h.

◆ INDEX_PARAMETER_VALUE_VALUE

const int berry::ParameterizedCommand::INDEX_PARAMETER_VALUE_VALUE
static

The index of the value of the parameter that the command can understand.

Deprecated:
no longer used

Definition at line 75 of file berryParameterizedCommand.h.


The documentation for this class was generated from the following file: