NCBI C++ ToolKit
plugin.hpp
Go to the documentation of this file.

Go to the SVN repository for this file.

1 #ifndef GUI_PLUGIN_PLUGIN_HPP
2 #define GUI_PLUGIN_PLUGIN_HPP
3 
4 /* $Id: plugin.hpp 14666 2007-07-09 13:40:22Z dicuccio $
5  * ===========================================================================
6  *
7  * PUBLIC DOMAIN NOTICE
8  * National Center for Biotechnology Information
9  *
10  * This software/database is a "United States Government Work" under the
11  * terms of the United States Copyright Act. It was written as part of
12  * the author's official duties as a United States Government employee and
13  * thus cannot be copyrighted. This software/database is freely available
14  * to the public for use. The National Library of Medicine and the U.S.
15  * Government have not placed any restriction on its use or reproduction.
16  *
17  * Although all reasonable efforts have been taken to ensure the accuracy
18  * and reliability of the software and data, the NLM and the U.S.
19  * Government do not and cannot warrant the performance or results that
20  * may be obtained by using this software or data. The NLM and the U.S.
21  * Government disclaim all warranties, express or implied, including
22  * warranties of performance, merchantability or fitness for any particular
23  * purpose.
24  *
25  * Please cite the author in any work or product based on this material.
26  *
27  * ===========================================================================
28  *
29  * Authors: Mati Shomrat
30  *
31  * File Description:
32  * CPlugin - defines a base interface for all plugins
33  */
34 #include <corelib/ncbistd.hpp>
35 #include <gui/gui_export.h>
37 #include <gui/core/resolver.hpp>
38 #include <gui/utils/reporter.hpp>
39 
40 
43  class CPluginInfoSet;
44  class CPluginArg;
45  class CPluginArgSet;
47 
49 
51 {
52 public:
53  /// destructor
54  virtual ~CPluginBase(void);
55 
56  /// @name Message-passing interface
57  /// @{
58 
59  /// pass a message to the plugin
60  /// This function will perform validation on the message and delegate
61  /// actual handling to user-overridable methods.
62  void Execute(objects::CPluginMessage& msg);
63 
64  /// Initialize the plugin. This maps to the plugin command
65  /// CPluginCommand::eCommand_init, and takes no arguments. No specific
66  /// registration is needed to obtain this command; however, if you want
67  /// to register 'init' as an auto-initializable command (i.e., a command
68  /// launched at application start-up), then you will need to register the
69  /// command. This command is implicitly supported by all plugins. The
70  /// provided plugin message is largely for future extension.
71  virtual void Init(objects::CPluginMessage& msg);
72 
73  virtual void CreateInterface(objects::CPluginMessage& msg);
74 
75  /// Execute the 'load' command. This maps to CPluginCommand::eCommand_load.
76  /// Use of this command requires registration in the plugin's information
77  /// settings, and explicit override from the user. Calling this command
78  /// on a plugin that does not support it will result in an exception.
79  virtual void Load(objects::CPluginMessage& msg);
80 
81  /// Execute the 'save' command. This maps to CPluginCommand::eCommand_save.
82  /// Use of this command requires registration in the plugin's information
83  /// settings, and explicit override from the user. Calling this command
84  /// on a plugin that does not support it will result in an exception.
85  virtual void Save(objects::CPluginMessage& msg);
86 
87  /// Execute the 'import' command. This maps to CPluginCommand::eCommand_import.
88  /// Use of this command requires registration in the plugin's information
89  /// settings, and explicit override from the user. Calling this command
90  /// on a plugin that does not support it will result in an exception.
91  virtual void Import(objects::CPluginMessage& msg);
92 
93  /// Execute the 'load-project' command. This maps to
94  /// CPluginCommand::eCommand_load_project. Use of this command requires
95  /// registration in the plugin's information settings, and explicit override
96  /// from the user. Calling this command on a plugin that does not support it
97  /// will result in an exception. This command is implicitly supported by all
98  /// data plugins so that the framework can generically call LoadProject on
99  /// any data plugin.
100  virtual void LoadProject(objects::CPluginMessage& msg);
101 
102  /// Execute the 'save-project' command. This maps to
103  /// CPluginCommand::eCommand_save_project. Use of this command requires
104  /// registration in the plugin's information settings, and explicit override
105  /// from the user. Calling this command on a plugin that does not support it
106  /// will result in an exception. This command is implicitly supported by all
107  /// data plugins so that the framework can generically call LoadProject on any
108  /// data plugin.
109  virtual void SaveProject(objects::CPluginMessage& msg);
110 
111  /// Execute the 'search' command. This maps to CPluginCommand::eCommand_search.
112  /// Use of this command requires registration in the plugin's information
113  /// settings, and explicit override from the user. Calling this command on a
114  /// plugin that does not support it will result in an exception.
115  virtual void Search(objects::CPluginMessage& msg);
116 
117  /// Execute the 'manage' command. This maps to CPluginCommand::eCommand_manage.
118  /// Use of this command requires registration in the plugin's information
119  /// settings, and explicit override from the user. Calling this command on a
120  /// plugin that does not support it will result in an exception.
121  virtual void Manage(objects::CPluginMessage& msg);
122 
123  /// Execute the 'run' command. This maps to CPluginCommand::eCommand_run.
124  /// Use of this command requires registration in the plugin's information
125  /// settings, and explicit override from the user. Calling this command on a
126  /// plugin that does not support it will result in an exception.
127  virtual void Run(objects::CPluginMessage& msg);
128 
129  /// Wait until the plugin has completed its execution. Plugins that override
130  /// this API should block until execution of their plugin has completed. This
131  /// maps to the plugin command CPluginCommand::eCommand_finish. This command
132  /// is implicitly supported by all plugins. The provided plugin message is
133  /// largely for future extension.
134  virtual void Finish(objects::CPluginMessage& msg);
135 
136  /// Attempt to stop a plugin's operation immediately. This maps to the plugin
137  /// command CPluginCommand::eCommand_abort. If a plugin manages a thread of
138  /// its own, it must respond to this command and block until the thread has
139  /// been stopped. This command is implicitly supported by all plugins. The
140  /// provided plugin message is largely for future extension.
141  virtual void Abort(objects::CPluginMessage& msg);
142 
143  /// Pause execution of a plugin. This maps to the plugin command
144  /// CPluginCommand::eCommand_suspend. This command is implicitly supported by
145  /// all plugins. If a plugin manages a thread, it should overload this function
146  /// and provide a blocking thread suspension. The provided plugin message is
147  /// largely for future extension.
148  virtual void Suspend(objects::CPluginMessage& msg);
149 
150  /// Resume execution of a paused plugin. This maps to the plugin command
151  /// CPluginCommand::eCommand_resume. This command is implicitly supported by
152  /// all plugins. If a plugin manages a thread, it should overload this function
153  /// and provide a blocking thread resumption. The provided plugin message is
154  /// largely for future extension.
155  virtual void Resume(objects::CPluginMessage& msg);
156 
157  /// Create a new view. This maps to the plugin command
158  /// CPluginCommand::eCommand_new_view. Use of this command requires
159  /// registration in the plugin's information settings, and explicit override
160  /// from the user. Calling this command on a plugin that does not support it
161  /// will result in an exception.
162  virtual void NewView(objects::CPluginMessage& msg);
163 
164  /// Create a new composite view. This maps to the plugin command
165  /// CPluginCommand::eCommand_new_composite_view. A composite view differs from
166  /// a regular view in that a composite view serves as a container for other
167  /// views. Composite views are derived from IViewComposite or CViewComposite.
168  /// Use of this command requires registration in the plugin's information
169  /// settings, and explicit override from the user. Calling this command on a
170  /// plugin that does not support it will result in an exception.
171  virtual void NewCompositeView(objects::CPluginMessage& msg);
172 
173  /// Retrieve some status information about the current execution. GetStatus()
174  /// is passed a message with two arguments - 'pct_completed' and 'message' -
175  /// so that a plugin can fill in some basic status information
176  virtual void GetStatus(objects::CPluginMessage& msg);
177 
178  /// @}
179 
180  /// @name Message-free interface
181  /// @{
182 
183  /// Status inquiry: Are we still running? The default implementation returns
184  /// true, and assumes that all tasks are running in a non-threaded, blocking
185  /// fashion. If an algorithm is managing a thread or interactive dialog,
186  /// this function should be overridden to prevent the instance from being
187  /// deleted until interaction or computation is completed.
188  virtual bool IsCompleted(void) const;
189 
190  /// Retrieve information about a plugin's arguments, class names, and so forth.
191  virtual void GetPluginInfo(objects::CPluginInfoSet& info) const = 0;
192 
193  /// Finalize the arguments (gets called just before argument dialog).
194  /// Version defined here does nothing; subclasses should override
195  /// if they want to do something.
196  virtual void FinalizeArgs(objects::CPluginMessage& msg);
197 
198  /// Validate all the arguments (gets called just after argument dialog).
199  /// If arguments are not valid, it thows an exception. Primarily it is
200  /// to be catched in PluginArgDialog, so it is of CDDV_DDX_Exception type.
201  /// Version defined here does nothing; subclasses should override
202  /// if they want to do something.
203  virtual objects::CPluginArg* ValidateArgs(objects::CPluginArgSet& set);
204 
205  /// This is the way to provide customized resolving dialog for particular
206  /// plugin. By default, it returns NULL, thus standard global resolver will
207  /// be used.
209 
210  /// This is the way to provide a dynamic behaviour of automatically generated
211  /// PluginArgForm.
213 
214  /// @}
215 };
216 
217 
218 template<typename PluginType>
219 class CPlugin : public CPluginBase
220 {
221 public:
222  /// overloaded GetInfo() - we call a static function in our derived plugin
223  /// type. This static function is a requirement of all plugin
224  /// implementations.
225  virtual void GetPluginInfo(objects::CPluginInfoSet& info) const
226  {
227  PluginType::GetInfo(info);
228  }
229 };
230 
231 
233 
234 #endif /// GUI_PLUGIN_PLUGIN_HPP
CObject –.
Definition: ncbiobj.hpp:180
namespace ncbi::objects::
virtual void GetPluginInfo(objects::CPluginInfoSet &info) const =0
Retrieve information about a plugin's arguments, class names, and so forth.
virtual void CreateInterface(objects::CPluginMessage &msg)
virtual void Import(objects::CPluginMessage &msg)
Execute the 'import' command.
virtual FPluginArgCallback GetPluginArgCallback()
This is the way to provide a dynamic behaviour of automatically generated PluginArgForm.
virtual void GetStatus(objects::CPluginMessage &msg)
Retrieve some status information about the current execution.
virtual void Suspend(objects::CPluginMessage &msg)
Pause execution of a plugin.
virtual FResolvePluginArgs GetArgsResolver()
This is the way to provide customized resolving dialog for particular plugin.
virtual objects::CPluginArg * ValidateArgs(objects::CPluginArgSet &set)
Validate all the arguments (gets called just after argument dialog).
virtual void Resume(objects::CPluginMessage &msg)
Resume execution of a paused plugin.
virtual void Manage(objects::CPluginMessage &msg)
Execute the 'manage' command.
virtual void Finish(objects::CPluginMessage &msg)
Wait until the plugin has completed its execution.
virtual void Search(objects::CPluginMessage &msg)
Execute the 'search' command.
virtual void Load(objects::CPluginMessage &msg)
Execute the 'load' command.
virtual void Init(objects::CPluginMessage &msg)
Initialize the plugin.
virtual ~CPluginBase(void)
destructor
virtual void NewView(objects::CPluginMessage &msg)
Create a new view.
void Execute(objects::CPluginMessage &msg)
pass a message to the plugin This function will perform validation on the message and delegate actual...
virtual void FinalizeArgs(objects::CPluginMessage &msg)
Finalize the arguments (gets called just before argument dialog).
virtual void NewCompositeView(objects::CPluginMessage &msg)
Create a new composite view.
virtual void Abort(objects::CPluginMessage &msg)
Attempt to stop a plugin's operation immediately.
virtual void Save(objects::CPluginMessage &msg)
Execute the 'save' command.
virtual bool IsCompleted(void) const
Status inquiry: Are we still running? The default implementation returns true, and assumes that all t...
virtual void Run(objects::CPluginMessage &msg)
Execute the 'run' command.
virtual void SaveProject(objects::CPluginMessage &msg)
Execute the 'save-project' command.
virtual void LoadProject(objects::CPluginMessage &msg)
Execute the 'load-project' command.
@PluginInfoSet.hpp User-defined methods of the data storage class.
virtual void GetPluginInfo(objects::CPluginInfoSet &info) const
overloaded GetInfo() - we call a static function in our derived plugin type.
Definition: plugin.hpp:225
Definition: set.hpp:45
Include a standard set of the NCBI C++ Toolkit most basic headers.
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define END_SCOPE(ns)
End the previously defined scope.
Definition: ncbistl.hpp:75
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
#define BEGIN_SCOPE(ns)
Define a new scope.
Definition: ncbistl.hpp:72
#define NCBI_GUIOBJECTS_EXPORT
Definition: gui_export.h:511
Defines to provide correct exporting from DLLs in Windows.
bool(* FResolvePluginArgs)(objects::CPluginMessage &msg, const TConstScopedObjects &selections)
Definition: resolver.hpp:41
static MDB_envinfo info
Definition: mdb_load.c:37
void(* FPluginArgCallback)(objects::CPluginArg &arg, objects::CPluginArgSet &set)
Definition: plugin.hpp:48
Modified on Sat Dec 09 04:48:00 2023 by modify_doxy.py rev. 669887