Medical Imaging Interaction Toolkit  2016.11.0
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) static const int INDEX_PARAMETER_ID
 
 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_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 44 of file berryParameterizedCommand.h.

Constructor & Destructor Documentation

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.

Definition at line 41 of file berryParameterizedCommand.cpp.

Referenced by GenerateCombinations(), and GenerateCommand().

Member Function Documentation

berry::ParameterizedCommand::berryObjectMacro ( ParameterizedCommand  ) const

The index of the parameter id in the parameter values.

Deprecated:
no longer used
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.

Definition at line 120 of file berryParameterizedCommand.cpp.

References GetParameterMap().

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.

Definition at line 256 of file berryParameterizedCommand.cpp.

References ParameterizedCommand().

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

Definition at line 278 of file berryParameterizedCommand.cpp.

References ParameterizedCommand().

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.

Definition at line 128 of file berryParameterizedCommand.cpp.

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.

Definition at line 133 of file berryParameterizedCommand.cpp.

Referenced by operator<(), and Serialize().

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.

Definition at line 138 of file berryParameterizedCommand.cpp.

References berry::Parameterization::GetParameter(), and berry::Parameterization::GetValueName().

Referenced by operator<().

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.

Definition at line 173 of file berryParameterizedCommand.cpp.

References berry::Parameterization::GetParameter(), and berry::Parameterization::GetValue().

Referenced by ExecuteWithChecks().

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

Returns a hash code value for the object.

Reimplemented from berry::Object.

Definition at line 185 of file berryParameterizedCommand.cpp.

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

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

Reimplemented from berry::Object.

Definition at line 74 of file berryParameterizedCommand.cpp.

References GetId(), and GetName().

bool berry::ParameterizedCommand::operator== ( const Object o) 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.

Definition at line 100 of file berryParameterizedCommand.cpp.

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 = <u>commandId</u> [ '(' parameters ')' ]
parameters = parameter [ ',' parameters ]
parameter = <u>parameterId</u> [ '=' <u>parameterValue</u> ]

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

<u>commandId</u> represents the command id encoded with separator characters escaped. <u>parameterId</u> and <u>parameterValue</u> 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 <u>parameterValue</u> 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)

Definition at line 204 of file berryParameterizedCommand.cpp.

References GetId(), berry::Parameterization::GetParameter(), berry::Parameterization::GetValue(), berry::CommandManager::ID_VALUE_CHAR, berry::CommandManager::PARAMETER_END_CHAR, berry::CommandManager::PARAMETER_SEPARATOR_CHAR, and berry::CommandManager::PARAMETER_START_CHAR.

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

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

Reimplemented from berry::Object.

Definition at line 246 of file berryParameterizedCommand.cpp.

Member Data Documentation

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 64 of file berryParameterizedCommand.h.

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 72 of file berryParameterizedCommand.h.

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 79 of file berryParameterizedCommand.h.


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