Medical Imaging Interaction Toolkit
2016.11.0
Medical Imaging Interaction Toolkit
|
#include <berryParameterizedCommand.h>
Public Member Functions | |
berryObjectMacro (ParameterizedCommand) static const int INDEX_PARAMETER_ID | |
ParameterizedCommand (const SmartPointer< Command > &command, const QList< Parameterization > ¶meterizations) | |
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< Command > | GetCommand () 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::TypeInfo > | GetSuperclasses () 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::Pointer > | GenerateCombinations (const SmartPointer< Command > command) |
static ParameterizedCommand::Pointer | GenerateCommand (const SmartPointer< Command > command, const QHash< QString, Object::Pointer > ¶meters) |
Static Public Member Functions inherited from berry::Object | |
static const char * | GetStaticClassName () |
static Reflection::TypeInfo | GetStaticTypeInfo () |
static QList< Reflection::TypeInfo > | GetStaticSuperclasses () |
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< Self > | Pointer |
typedef berry::SmartPointer< const Self > | ConstPointer |
typedef berry::WeakPointer< Self > | WeakPtr |
typedef berry::WeakPointer< const Self > | ConstWeakPtr |
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 |
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.
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.
command | The command that is parameterized; must not be null . |
parameterizations | An 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().
berry::ParameterizedCommand::berryObjectMacro | ( | ParameterizedCommand | ) | const |
The index of the parameter id in the parameter values.
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.
trigger | The object that triggered the execution; may be null . |
applicationContext | The state of the application at the time the execution was triggered; may be null . |
null
. ExecutionException | If the handler has problems executing this command. |
NotDefinedException | If the command you are trying to execute is not defined. |
NotEnabledException | If the command you are trying to execute is not enabled. |
NotHandledException | If there is no handler. |
Definition at line 120 of file berryParameterizedCommand.cpp.
References GetParameterMap().
|
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.
command | The command for which the parameter combinations should be generated; must not be null . |
ParameterizedCommand
instances representing all of the possible combinations. This value is never empty and it is never null
. NotDefinedException | If the command is not defined. |
Definition at line 256 of file berryParameterizedCommand.cpp.
References ParameterizedCommand().
|
static |
Take a command and a map of parameter IDs to values, and generate the appropriate parameterized command.
command | The command object. Must not be null . |
parameters | A map of String parameter ids to objects. May be null . |
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.
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.
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.
null
. NotDefinedException | If 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
.
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().
|
overridevirtual |
Returns a hash code value for the object.
Reimplemented from berry::Object.
Definition at line 185 of file berryParameterizedCommand.cpp.
|
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.
|
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)
null
. 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.
|
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.
|
static |
The index of the human-readable name of the parameter itself, in the parameter values.
Definition at line 64 of file berryParameterizedCommand.h.
|
static |
The index of the human-readable name of the value of the parameter for this command.
Definition at line 72 of file berryParameterizedCommand.h.
|
static |
The index of the value of the parameter that the command can understand.
Definition at line 79 of file berryParameterizedCommand.h.