PCL
ProcessInstance.h
Go to the documentation of this file.
1 // ____ ______ __
2 // / __ \ / ____// /
3 // / /_/ // / / /
4 // / ____// /___ / /___ PixInsight Class Library
5 // /_/ \____//_____/ PCL 2.7.0
6 // ----------------------------------------------------------------------------
7 // pcl/ProcessInstance.h - Released 2024-06-18T15:48:54Z
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-2024 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 
116  ~ProcessInstance() override
117  {
118  }
119 
126 
132 
148  uint32 Version() const;
149 
157  ProcessInstance& operator =( const ProcessInstance& p )
158  {
159  SetHandle( p.handle );
160  return *this;
161  }
162 
169 
188  bool Assign( const ProcessInstance& p );
189 
200  bool Validate( String& whyNot );
201 
210  bool IsHistoryUpdater( const View& view ) const;
211 
220  bool IsMaskable( const View& view, const ImageWindow& mask ) const;
221 
232  bool CanExecuteOn( const View& view, String& whyNot ) const;
233 
267  bool ExecuteOn( View& view, bool swapFile = true );
268 
286  bool CanExecuteGlobal( String& whyNot ) const;
287 
296 
307  bool CanExecuteOn( const ImageVariant& image, String& whyNot ) const;
308 
326  bool ExecuteOn( ImageVariant& image, const IsoString& hints = IsoString() );
327 
328  bool ExecuteOn( ImageVariant& image, const IsoString::ustring_base& hints )
329  {
330  return ExecuteOn( image, IsoString( hints ) );
331  }
332 
352  bool Launch();
353 
363  bool CanLaunchInterface() const;
364 
372 
383 
390  void SetDescription( const String& text );
391 
402  void GetExecutionTimes( double& startJD, double& elapsedSecs ) const;
403 
409  double StartJD() const
410  {
411  double startJD, dum;
412  GetExecutionTimes( startJD, dum );
413  return startJD;
414  }
415 
421  double ElapsedTime() const
422  {
423  double dum, elapsedSecs;
424  GetExecutionTimes( dum, elapsedSecs );
425  return elapsedSecs;
426  }
427 
450  String ToSource( const IsoString& language = "JavaScript",
451  const IsoString& varId = IsoString(), int indent = 0 ) const;
452 
460  static ProcessInstance FromSource( const String& source,
461  const IsoString& language = "JavaScript" );
462 
471  static ProcessInstance FromIcon( const IsoString& iconId );
472 
473  static ProcessInstance FromIcon( const IsoString::ustring_base& iconId )
474  {
475  return FromIcon( IsoString( iconId ) );
476  }
477 
483 
489  static IsoStringList IconsByProcessId( const IsoString& processId );
490 
491  static IsoStringList IconsByProcessId( const IsoString::ustring_base& processId )
492  {
493  return IconsByProcessId( IsoString( processId ) );
494  }
495 
535  Variant ParameterValue( const ProcessParameter& parameter, size_type rowIndex = ~size_type( 0 ) ) const;
536 
546  Variant ParameterValue( const IsoString& parameterId, size_type rowIndex = ~size_type( 0 ) ) const
547  {
548  return ParameterValue( ProcessParameter( ParentProcess(), parameterId ), rowIndex );
549  }
550 
551  Variant ParameterValue( const IsoString::ustring_base& parameterId, size_type rowIndex = ~size_type( 0 ) ) const
552  {
553  return ParameterValue( IsoString( parameterId ), rowIndex );
554  }
555 
600  bool SetParameterValue( const Variant& value,
601  const ProcessParameter& parameter, size_type rowIndex = ~size_type( 0 ) );
602 
612  bool SetParameterValue( const Variant& value, const IsoString& parameterId, size_type rowIndex = ~size_type( 0 ) )
613  {
614  return SetParameterValue( value, ProcessParameter( ParentProcess(), parameterId ), rowIndex );
615  }
616 
617  bool SetParameterValue( const Variant& value, const IsoString::ustring_base& parameterId, size_type rowIndex = ~size_type( 0 ) )
618  {
619  return SetParameterValue( value, IsoString( parameterId ), rowIndex );
620  }
621 
630  size_type TableRowCount( const ProcessParameter& table ) const;
631 
641  size_type TableRowCount( const IsoString& tableId ) const
642  {
643  return TableRowCount( ProcessParameter( ParentProcess(), tableId ) );
644  }
645 
646  size_type TableRowCount( const IsoString::ustring_base& tableId ) const
647  {
648  return TableRowCount( IsoString( tableId ) );
649  }
650 
671  bool AllocateTableRows( const ProcessParameter& table, size_type rowCount );
672 
682  bool AllocateTableRows( const IsoString& tableId, size_type rowCount )
683  {
684  return AllocateTableRows( ProcessParameter( ParentProcess(), tableId ), rowCount );
685  }
686 
687  bool AllocateTableRows( const IsoString::ustring_base& tableId, size_type rowCount )
688  {
689  return AllocateTableRows( IsoString( tableId ), rowCount );
690  }
691 
692 private:
693 
694  ProcessInstance( void* h ) : UIObject( h )
695  {
696  }
697 
698  ProcessInstance( const void* h ) : UIObject( h )
699  {
700  }
701 
702  void* CloneHandle() const override;
703 
704  friend class ProcessInstancePrivate;
705  friend class InterfaceDispatcher;
706  friend class InternalIconEnumerator;
707 };
708 
709 // ----------------------------------------------------------------------------
710 
711 } // pcl
712 
713 #endif // __PCL_BUILDING_PIXINSIGHT_APPLICATION
714 
715 #endif // __PCL_ProcessInstance_h
716 
717 // ----------------------------------------------------------------------------
718 // EOF pcl/ProcessInstance.h - Released 2024-06-18T15:48:54Z
Acts like a union for all types of images in PCL, with optional class-wide ownership of transported i...
Definition: ImageVariant.h:322
High-level interface to an image window object in the PixInsight core application.
Definition: ImageWindow.h:287
Eight-bit string (ISO/IEC-8859-1 or UTF-8 string)
Definition: String.h:5425
High-level interface to a process instance.
static ProcessInstance FromSource(const String &source, const IsoString &language="JavaScript")
Process ParentProcess() const
bool IsMaskable(const View &view, const ImageWindow &mask) const
String Description() const
ProcessInstance(const ProcessInstance &p)
ProcessInstance(const Process &process)
size_type TableRowCount(const IsoString &tableId) const
static ProcessInstance & Null()
bool CanExecuteOn(const ImageVariant &image, String &whyNot) const
bool SetParameterValue(const Variant &value, const ProcessParameter &parameter, size_type rowIndex=~size_type(0))
static ProcessInstance FromIcon(const IsoString &iconId)
double StartJD() const
bool Validate(String &whyNot)
void GetExecutionTimes(double &startJD, double &elapsedSecs) const
size_type TableRowCount(const ProcessParameter &table) const
bool ExecuteOn(ImageVariant &image, const IsoString &hints=IsoString())
bool CanLaunchInterface() const
ProcessInstance Clone() const
bool SetParameterValue(const Variant &value, const IsoString &parameterId, size_type rowIndex=~size_type(0))
Variant ParameterValue(const ProcessParameter &parameter, size_type rowIndex=~size_type(0)) const
bool Assign(const ProcessInstance &p)
uint32 Version() const
void SetDescription(const String &text)
bool CanExecuteOn(const View &view, String &whyNot) const
static IsoStringList Icons()
bool ExecuteOn(View &view, bool swapFile=true)
bool AllocateTableRows(const IsoString &tableId, size_type rowCount)
Variant ParameterValue(const IsoString &parameterId, size_type rowIndex=~size_type(0)) const
String ToSource(const IsoString &language="JavaScript", const IsoString &varId=IsoString(), int indent=0) const
bool AllocateTableRows(const ProcessParameter &table, size_type rowCount)
double ElapsedTime() const
static IsoStringList IconsByProcessId(const IsoString &processId)
bool IsHistoryUpdater(const View &view) const
bool CanExecuteGlobal(String &whyNot) const
Identifies and describes a process parameter.
High-level interface to an installed process.
Definition: Process.h:99
Unicode (UTF-16) string.
Definition: String.h:8113
Root base class for all user interface objects.
Definition: UIObject.h:95
Acts like a union to store instances of different data types.
Definition: Variant.h:332
High-level interface to a PixInsight view object.
Definition: View.h:213
unsigned int uint32
Definition: Defs.h:666
size_t size_type
Definition: Defs.h:609
PCL root namespace.
Definition: AbstractImage.h:77