PCL
ProcessInstance.h
Go to the documentation of this file.
1 // ____ ______ __
2 // / __ \ / ____// /
3 // / /_/ // / / /
4 // / ____// /___ / /___ PixInsight Class Library
5 // /_/ \____//_____/ PCL 2.4.7
6 // ----------------------------------------------------------------------------
7 // pcl/ProcessInstance.h - Released 2020-12-17T15:46:28Z
8 // ----------------------------------------------------------------------------
9 // This file is part of the PixInsight Class Library (PCL).
10 // PCL is a multiplatform C++ framework for development of PixInsight modules.
11 //
12 // Copyright (c) 2003-2020 Pleiades Astrophoto S.L. All Rights Reserved.
13 //
14 // Redistribution and use in both source and binary forms, with or without
15 // modification, is permitted provided that the following conditions are met:
16 //
17 // 1. All redistributions of source code must retain the above copyright
18 // notice, this list of conditions and the following disclaimer.
19 //
20 // 2. All redistributions in binary form must reproduce the above copyright
21 // notice, this list of conditions and the following disclaimer in the
22 // documentation and/or other materials provided with the distribution.
23 //
24 // 3. Neither the names "PixInsight" and "Pleiades Astrophoto", nor the names
25 // of their contributors, may be used to endorse or promote products derived
26 // from this software without specific prior written permission. For written
27 // permission, please contact info@pixinsight.com.
28 //
29 // 4. All products derived from this software, in any form whatsoever, must
30 // reproduce the following acknowledgment in the end-user documentation
31 // and/or other materials provided with the product:
32 //
33 // "This product is based on software from the PixInsight project, developed
34 // by Pleiades Astrophoto and its contributors (https://pixinsight.com/)."
35 //
36 // Alternatively, if that is where third-party acknowledgments normally
37 // appear, this acknowledgment must be reproduced in the product itself.
38 //
39 // THIS SOFTWARE IS PROVIDED BY PLEIADES ASTROPHOTO AND ITS CONTRIBUTORS
40 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
41 // TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
42 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL PLEIADES ASTROPHOTO OR ITS
43 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
44 // EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, BUSINESS
45 // INTERRUPTION; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; AND LOSS OF USE,
46 // DATA OR PROFITS) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
47 // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
48 // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
49 // POSSIBILITY OF SUCH DAMAGE.
50 // ----------------------------------------------------------------------------
51 
52 #ifndef __PCL_ProcessInstance_h
53 #define __PCL_ProcessInstance_h
54 
56 
57 #ifndef __PCL_BUILDING_PIXINSIGHT_APPLICATION
58 
59 #include <pcl/Defs.h>
60 
61 #include <pcl/Process.h>
62 #include <pcl/ProcessParameter.h>
63 #include <pcl/Variant.h>
64 
65 namespace pcl
66 {
67 
68 // ----------------------------------------------------------------------------
69 
70 class PCL_CLASS Process;
71 class PCL_CLASS ImageWindow;
72 class PCL_CLASS View;
73 
86 class PCL_CLASS ProcessInstance : public UIObject
87 {
88 public:
89 
95  ProcessInstance( const Process& process );
96 
106  {
107  }
108 
117  {
118  }
119 
125  static ProcessInstance& Null();
126 
131  Process ParentProcess() const;
132 
140  ProcessInstance& operator =( const ProcessInstance& p )
141  {
142  SetHandle( p.handle );
143  return *this;
144  }
145 
151  ProcessInstance Clone() const;
152 
171  bool Assign( const ProcessInstance& p );
172 
183  bool Validate( String& whyNot );
184 
193  bool IsHistoryUpdater( const View& view ) const;
194 
203  bool IsMaskable( const View& view, const ImageWindow& mask ) const;
204 
215  bool CanExecuteOn( const View& view, String& whyNot ) const;
216 
250  bool ExecuteOn( View& view, bool swapFile = true );
251 
269  bool CanExecuteGlobal( String& whyNot ) const;
270 
278  bool ExecuteGlobal();
279 
290  bool CanExecuteOn( const ImageVariant& image, String& whyNot ) const;
291 
309  bool ExecuteOn( ImageVariant& image, const IsoString& hints = IsoString() );
310 
311  bool ExecuteOn( ImageVariant& image, const IsoString::ustring_base& hints )
312  {
313  return ExecuteOn( image, IsoString( hints ) );
314  }
315 
335  bool Launch();
336 
346  bool CanLaunchInterface() const;
347 
354  bool LaunchInterface();
355 
365  String Description() const;
366 
373  void SetDescription( const String& text );
374 
385  void GetExecutionTimes( double& startJD, double& elapsedSecs ) const;
386 
392  double StartJD() const
393  {
394  double startJD, dum;
395  GetExecutionTimes( startJD, dum );
396  return startJD;
397  }
398 
404  double ElapsedTime() const
405  {
406  double dum, elapsedSecs;
407  GetExecutionTimes( dum, elapsedSecs );
408  return elapsedSecs;
409  }
410 
433  String ToSource( const IsoString& language = "JavaScript",
434  const IsoString& varId = IsoString(), int indent = 0 ) const;
435 
443  static ProcessInstance FromSource( const String& source,
444  const IsoString& language = "JavaScript" );
445 
454  static ProcessInstance FromIcon( const IsoString& iconId );
455 
456  static ProcessInstance FromIcon( const IsoString::ustring_base& iconId )
457  {
458  return FromIcon( IsoString( iconId ) );
459  }
460 
465  static IsoStringList Icons();
466 
472  static IsoStringList IconsByProcessId( const IsoString& processId );
473 
474  static IsoStringList IconsByProcessId( const IsoString::ustring_base& processId )
475  {
476  return IconsByProcessId( IsoString( processId ) );
477  }
478 
518  Variant ParameterValue( const ProcessParameter& parameter, size_type rowIndex = ~size_type( 0 ) ) const;
519 
529  Variant ParameterValue( const IsoString& parameterId, size_type rowIndex = ~size_type( 0 ) ) const
530  {
531  return ParameterValue( ProcessParameter( ParentProcess(), parameterId ), rowIndex );
532  }
533 
534  Variant ParameterValue( const IsoString::ustring_base& parameterId, size_type rowIndex = ~size_type( 0 ) ) const
535  {
536  return ParameterValue( IsoString( parameterId ), rowIndex );
537  }
538 
583  bool SetParameterValue( const Variant& value,
584  const ProcessParameter& parameter, size_type rowIndex = ~size_type( 0 ) );
585 
595  bool SetParameterValue( const Variant& value, const IsoString& parameterId, size_type rowIndex = ~size_type( 0 ) )
596  {
597  return SetParameterValue( value, ProcessParameter( ParentProcess(), parameterId ), rowIndex );
598  }
599 
600  bool SetParameterValue( const Variant& value, const IsoString::ustring_base& parameterId, size_type rowIndex = ~size_type( 0 ) )
601  {
602  return SetParameterValue( value, IsoString( parameterId ), rowIndex );
603  }
604 
613  size_type TableRowCount( const ProcessParameter& table ) const;
614 
624  size_type TableRowCount( const IsoString& tableId ) const
625  {
626  return TableRowCount( ProcessParameter( ParentProcess(), tableId ) );
627  }
628 
629  size_type TableRowCount( const IsoString::ustring_base& tableId ) const
630  {
631  return TableRowCount( IsoString( tableId ) );
632  }
633 
654  bool AllocateTableRows( const ProcessParameter& table, size_type rowCount );
655 
665  bool AllocateTableRows( const IsoString& tableId, size_type rowCount )
666  {
667  return AllocateTableRows( ProcessParameter( ParentProcess(), tableId ), rowCount );
668  }
669 
670  bool AllocateTableRows( const IsoString::ustring_base& tableId, size_type rowCount )
671  {
672  return AllocateTableRows( IsoString( tableId ), rowCount );
673  }
674 
675 private:
676 
677  ProcessInstance( void* h ) : UIObject( h )
678  {
679  }
680 
681  ProcessInstance( const void* h ) : UIObject( h )
682  {
683  }
684 
685  void* CloneHandle() const override;
686 
687  friend class ProcessInstancePrivate;
688  friend class InterfaceDispatcher;
689  friend class InternalIconEnumerator;
690 };
691 
692 // ----------------------------------------------------------------------------
693 
694 } // pcl
695 
696 #endif // __PCL_BUILDING_PIXINSIGHT_APPLICATION
697 
698 #endif // __PCL_ProcessInstance_h
699 
700 // ----------------------------------------------------------------------------
701 // EOF pcl/ProcessInstance.h - Released 2020-12-17T15:46:28Z
Dynamic list of 8-bit strings.
PCL root namespace.
Definition: AbstractImage.h:76
Root base class for all user interface objects.
Definition: UIObject.h:94
Identifies and describes a process parameter.
size_t size_type
Definition: Defs.h:605
Acts like a union for all types of images in PCL, with optional class-wide ownership of transported i...
Definition: ImageVariant.h:317
bool SetParameterValue(const Variant &value, const IsoString &parameterId, size_type rowIndex=~size_type(0))
ProcessInstance(const ProcessInstance &p)
double StartJD() const
Unicode (UTF-16) string.
Definition: String.h:7923
Acts like a union to store instances of different data types.
Definition: Variant.h:331
High-level interface to a PixInsight view object.
Definition: View.h:212
High-level interface to an installed process.
Definition: Process.h:98
Variant ParameterValue(const IsoString &parameterId, size_type rowIndex=~size_type(0)) const
High-level interface to a process instance.
size_type TableRowCount(const IsoString &tableId) const
double ElapsedTime() const
bool AllocateTableRows(const IsoString &tableId, size_type rowCount)
High-level interface to an image window object in the PixInsight core application.
Definition: ImageWindow.h:284
Eight-bit string (ISO/IEC-8859-1 or UTF-8 string)
Definition: String.h:5397