PCL
ProcessImplementation.h
Go to the documentation of this file.
1 // ____ ______ __
2 // / __ \ / ____// /
3 // / /_/ // / / /
4 // / ____// /___ / /___ PixInsight Class Library
5 // /_/ \____//_____/ PCL 2.6.5
6 // ----------------------------------------------------------------------------
7 // pcl/ProcessImplementation.h - Released 2024-01-13T15:47:58Z
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_ProcessImplementation_h
53 #define __PCL_ProcessImplementation_h
54 
56 
57 #ifndef __PCL_BUILDING_PIXINSIGHT_APPLICATION
58 
59 #include <pcl/Defs.h>
60 
61 #include <pcl/ImageWindow.h>
62 #include <pcl/MetaProcess.h>
63 #include <pcl/String.h>
64 
65 namespace pcl
66 {
67 
68 // ----------------------------------------------------------------------------
69 
70 class PCL_CLASS MetaParameter;
71 class PCL_CLASS ProcessInterface;
72 class PCL_CLASS View;
73 class PCL_CLASS ImageWindow;
74 
75 // ----------------------------------------------------------------------------
76 
96 class PCL_CLASS ProcessImplementation
97 {
98 public:
99 
107  : meta( m )
108  {
109  }
110 
114  ProcessImplementation( const ProcessImplementation& ) = default;
115 
120  {
121  }
122 
128  const MetaProcess* Meta() const
129  {
130  return meta;
131  }
132 
148  uint32 Version() const;
149 
166  virtual void Initialize();
167 
186  virtual bool Validate( String& info );
187 
209  virtual void Assign( const ProcessImplementation& instance );
210 
244  virtual bool CanExecuteOn( const View& view, String& whyNot ) const;
245 
258  virtual bool IsHistoryUpdater( const View& view ) const
259  {
260  return true; // by default, all processes are supposed to update images.
261  }
262 
287  virtual bool IsMaskable( const View& view, const ImageWindow& mask ) const
288  {
289  return true; // by default, all processes are supposed to be maskable.
290  }
291 
313  virtual UndoFlags UndoMode( const View& view ) const
314  {
315  return UndoFlag::DefaultMode;
316  }
317 
335  virtual bool BeforeExecution( View& view )
336  {
337  return true;
338  }
339 
359  virtual bool ExecuteOn( View& view );
360 
372  virtual void AfterExecution( View& view )
373  {
374  }
375 
405  virtual bool CanExecuteOn( const ImageVariant& image, String& whyNot ) const;
406 
449  virtual bool ExecuteOn( ImageVariant& image, const IsoString& hints );
450 
481  virtual bool CanExecuteGlobal( String& whyNot ) const;
482 
495  virtual bool BeforeGlobalExecution()
496  {
497  return true;
498  }
499 
519  virtual bool ExecuteGlobal();
520 
528  virtual void AfterGlobalExecution()
529  {
530  }
531 
552  {
553  return meta->DefaultInterface(); // by default, process instances use
554  // their default interfaces.
555  }
556 
569  virtual bool IsValidInterface( const ProcessInterface* i ) const
570  {
571  return i == SelectInterface();
572  }
573 
591  virtual bool BeforeReading()
592  {
593  return true;
594  }
595 
606  virtual void AfterReading()
607  {
608  }
609 
627  virtual bool BeforeWriting() const
628  {
629  return true;
630  }
631 
642  virtual void AfterWriting() const
643  {
644  }
645 
670  virtual void* LockParameter( const MetaParameter* p, size_type tableRow );
671 
692  virtual void UnlockParameter( const MetaParameter* p, size_type tableRow );
693 
713  virtual bool ValidateParameter( void* value, const MetaParameter* p, size_type tableRow ) const;
714 
737  virtual bool AllocateParameter( size_type sizeOrLength, const MetaParameter* p, size_type tableRow );
738 
757  virtual size_type ParameterLength( const MetaParameter* p, size_type tableRow ) const;
758 
782  void Launch() const;
783 
791  void LaunchInterface() const;
792 
796  void LaunchGlobal() const;
797 
801  void LaunchOnCurrentView() const;
802 
807  void LaunchOnCurrentWindow() const;
808 
812  void LaunchOn( View& ) const;
813 
817  void LaunchOn( ImageWindow& ) const;
818 
819 protected:
820 
821  const MetaProcess* meta = nullptr;
822 
823 private:
824 
825  mutable const void* m_serverHandle = nullptr;
826 
827  friend class ProcessContextDispatcher;
828 };
829 
830 // ----------------------------------------------------------------------------
831 
832 } // pcl
833 
834 #endif // __PCL_BUILDING_PIXINSIGHT_APPLICATION
835 
836 #endif // __PCL_ProcessImplementation_h
837 
838 // ----------------------------------------------------------------------------
839 // EOF pcl/ProcessImplementation.h - Released 2024-01-13T15:47:58Z
pcl::ProcessImplementation::AfterReading
virtual void AfterReading()
Definition: ProcessImplementation.h:606
pcl
PCL root namespace.
Definition: AbstractImage.h:76
pcl::ProcessImplementation::BeforeWriting
virtual bool BeforeWriting() const
Definition: ProcessImplementation.h:627
pcl::ProcessImplementation::UndoMode
virtual UndoFlags UndoMode(const View &view) const
Definition: ProcessImplementation.h:313
pcl::ProcessImplementation::IsMaskable
virtual bool IsMaskable(const View &view, const ImageWindow &mask) const
Definition: ProcessImplementation.h:287
pcl::String
Unicode (UTF-16) string.
Definition: String.h:8112
pcl::ProcessImplementation::AfterWriting
virtual void AfterWriting() const
Definition: ProcessImplementation.h:642
pcl::IsoString
Eight-bit string (ISO/IEC-8859-1 or UTF-8 string)
Definition: String.h:5424
pcl::ProcessImplementation::SelectInterface
virtual ProcessInterface * SelectInterface() const
Definition: ProcessImplementation.h:551
pcl::View
High-level interface to a PixInsight view object.
Definition: View.h:212
pcl::uint32
unsigned int uint32
Definition: Defs.h:669
ImageWindow.h
pcl::ProcessImplementation::ProcessImplementation
ProcessImplementation(const MetaProcess *m)
Definition: ProcessImplementation.h:106
pcl::ProcessImplementation::AfterExecution
virtual void AfterExecution(View &view)
Definition: ProcessImplementation.h:372
pcl::ProcessImplementation::BeforeReading
virtual bool BeforeReading()
Definition: ProcessImplementation.h:591
MetaProcess.h
pcl::MetaParameter
Root base class for PCL classes providing formal descriptions of process parameters.
Definition: MetaParameter.h:99
pcl::size_type
size_t size_type
Definition: Defs.h:612
pcl::Version
Provides PCL version numbers.
Definition: Version.h:75
pcl::Flags
A type-safe collection of enumerated flags.
Definition: Flags.h:84
pcl::ProcessImplementation::~ProcessImplementation
virtual ~ProcessImplementation()
Definition: ProcessImplementation.h:119
pcl::ProcessImplementation::BeforeGlobalExecution
virtual bool BeforeGlobalExecution()
Definition: ProcessImplementation.h:495
pcl::ProcessImplementation::BeforeExecution
virtual bool BeforeExecution(View &view)
Definition: ProcessImplementation.h:335
pcl::ImageWindow
High-level interface to an image window object in the PixInsight core application.
Definition: ImageWindow.h:284
pcl::ProcessImplementation
Implementation of a PixInsight process instance.
Definition: ProcessImplementation.h:96
pcl::ProcessInterface
Client-side interface to a PixInsight process interface window.
Definition: ProcessInterface.h:255
String.h
pcl::ProcessImplementation::AfterGlobalExecution
virtual void AfterGlobalExecution()
Definition: ProcessImplementation.h:528
pcl::MetaProcess
A formal description of a PixInsight process.
Definition: MetaProcess.h:106
pcl::ProcessImplementation::IsValidInterface
virtual bool IsValidInterface(const ProcessInterface *i) const
Definition: ProcessImplementation.h:569
pcl::ImageVariant
Acts like a union for all types of images in PCL, with optional class-wide ownership of transported i...
Definition: ImageVariant.h:321
pcl::ProcessImplementation::IsHistoryUpdater
virtual bool IsHistoryUpdater(const View &view) const
Definition: ProcessImplementation.h:258
Defs.h
pcl::ProcessImplementation::Meta
const MetaProcess * Meta() const
Definition: ProcessImplementation.h:128