PCL
GlobalSettings.h
Go to the documentation of this file.
1 // ____ ______ __
2 // / __ \ / ____// /
3 // / /_/ // / / /
4 // / ____// /___ / /___ PixInsight Class Library
5 // /_/ \____//_____/ PCL 2.6.5
6 // ----------------------------------------------------------------------------
7 // pcl/GlobalSettings.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_GlobalSettings_h
53 #define __PCL_GlobalSettings_h
54 
56 
57 #include <pcl/Defs.h>
58 #include <pcl/Diagnostics.h>
59 
60 #include <pcl/Color.h>
61 #include <pcl/String.h>
62 
63 #ifndef __PCL_BUILDING_PIXINSIGHT_APPLICATION
64 #include <pcl/Font.h>
65 #endif
66 
67 namespace pcl
68 {
69 
70 // ----------------------------------------------------------------------------
71 
87 namespace GlobalVariableType
88 {
89  enum value_type
90  {
91  Undefined, // The requested global variable doesn't exist
92  Flag, // bool
93  Integer, // int
94  Unsigned, // unsigned
95  Real, // double
96  Color, // RGBA (= uint32)
97  Font, // Font
98  String // String
99  };
100 }
101 
102 // ----------------------------------------------------------------------------
103 
388 class PCL_CLASS PixInsightSettings
389 {
390 public:
391 
395  using variable_type = GlobalVariableType::value_type;
396 
401  PixInsightSettings() = delete;
402 
407  PixInsightSettings( const PixInsightSettings& ) = delete;
408 
413  PixInsightSettings& operator =( const PixInsightSettings& ) = delete;
414 
419  virtual ~PixInsightSettings() = delete;
420 
424  static variable_type GlobalVariableType( const IsoString& globalId );
425 
430  static bool IsGlobalVariableDefined( const IsoString& globalId )
431  {
432  return GlobalVariableType( globalId ) != GlobalVariableType::Undefined;
433  }
434 
438  static bool GlobalFlag( const IsoString& globalId );
439 
443  static int GlobalInteger( const IsoString& globalId );
444 
448  static unsigned GlobalUnsigned( const IsoString& globalId );
449 
453  static double GlobalReal( const IsoString& globalId );
454 
458  static RGBA GlobalColor( const IsoString& globalId );
459 
460 #ifndef __PCL_BUILDING_PIXINSIGHT_APPLICATION
461 
464  static Font GlobalFont( const IsoString& globalId );
465 #endif
466 
470  static String GlobalString( const IsoString& globalId );
471 
477  static void BeginUpdate();
478 
484  static void EndUpdate();
485 
495  static void CancelUpdate();
496 
500  static void SetGlobalFlag( const IsoString& globalId, bool );
501 
505  static void SetGlobalInteger( const IsoString& globalId, int );
506 
510  static void SetGlobalUnsigned( const IsoString& globalId, unsigned );
511 
515  static void SetGlobalReal( const IsoString& globalId, double );
516 
520  static void SetGlobalColor( const IsoString& globalId, RGBA );
521 
522 #ifndef __PCL_BUILDING_PIXINSIGHT_APPLICATION
523 
526  static void SetGlobalFont( const IsoString& globalId, const Font& );
527 #endif
528 
532  static void SetGlobalString( const IsoString& globalId, const String& );
533 };
534 
535 // ----------------------------------------------------------------------------
536 
537 } // pcl
538 
539 #endif // __PCL_GlobalSettings_h
540 
541 // ----------------------------------------------------------------------------
542 // EOF pcl/GlobalSettings.h - Released 2024-01-13T15:47:58Z
pcl
PCL root namespace.
Definition: AbstractImage.h:76
pcl::String
Unicode (UTF-16) string.
Definition: String.h:8112
pcl::IsoString
Eight-bit string (ISO/IEC-8859-1 or UTF-8 string)
Definition: String.h:5424
Font.h
pcl::PixInsightSettings
Retrieves global settings from the PixInsight core application.
Definition: GlobalSettings.h:388
pcl::RGBA
uint32 RGBA
Definition: Color.h:92
pcl::PixInsightSettings::IsGlobalVariableDefined
static bool IsGlobalVariableDefined(const IsoString &globalId)
Definition: GlobalSettings.h:430
pcl::Font
Client-side interface to a PixInsight Font object.
Definition: Font.h:206
String.h
Color.h
Defs.h