ItalaApi  1.3.3
Smart.h
Go to the documentation of this file.
1 
2 /***********************************************************************************
3  *
4  * ItalaApi - Copyright (C) 2022 Opto Engineering
5  *
6  * THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES,
7  * INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
8  * FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT
9  * HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY SUFFERED BY LICENSE AS
10  * A RESULT OF USING, MODIFYING OR DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES.
11  *
12  ***********************************************************************************/
13 
14 #ifndef ITALA_API_SMART_H
15 #define ITALA_API_SMART_H
16 
17 #include <memory>
18 #include "ItalaApi/IDevice.h"
19 #include "ItalaApi/IImage.h"
20 #include "ItalaApi/ISystem.h"
21 #include "ItalaApi/Polarization.h"
22 
47 namespace Itala {
48 
49 typedef std::shared_ptr<ISystem> SystemPtr;
50 typedef std::shared_ptr<IDevice> DevicePtr;
51 typedef std::shared_ptr<IImage> ImagePtr;
52 
53 inline SystemPtr SmartAssign(ISystem* pSystem) {
54  return SystemPtr(pSystem, [pSystem](Itala::ISystem* sys) { sys->Dispose(); });
55 }
56 
57 inline DevicePtr SmartAssign(IDevice* pDevice) {
58  return DevicePtr(pDevice, [pDevice](Itala::IDevice* dev) { dev->Dispose(); });
59 }
60 
61 inline ImagePtr SmartAssign(IImage* pImage) {
62  return ImagePtr(pImage, [pImage](Itala::IImage* img) { img->Dispose(); });
63 }
64 
65 struct SmartPolarComponents {
66  ImagePtr P0;
67  ImagePtr P45;
68  ImagePtr P90;
69  ImagePtr P135;
70  operator PolarComponents() const { return {P0.get(), P45.get(), P90.get(), P135.get()}; }
71 };
72 
73 struct SmartPolarComponentsColor {
74  SmartPolarComponents RedComponents, GreenComponents, BlueComponents;
75  operator PolarComponentsColor() const { return {RedComponents, GreenComponents, BlueComponents}; }
76 };
77 
78 struct SmartStokesVectors {
79  ImagePtr S0, S1, S2;
80  operator StokesVectors() const { return {S0.get(), S1.get(), S2.get()}; }
81 };
82 
83 inline SmartPolarComponents SmartAssign(PolarComponents polarComponents) {
84  return {SmartAssign(polarComponents.P0), SmartAssign(polarComponents.P45),
85  SmartAssign(polarComponents.P90), SmartAssign(polarComponents.P135)};
86 }
87 
88 inline SmartPolarComponentsColor SmartAssign(PolarComponentsColor& polarComponentsColor) {
89  return {SmartAssign(polarComponentsColor.RedComponents),
90  SmartAssign(polarComponentsColor.GreenComponents),
91  SmartAssign(polarComponentsColor.BlueComponents)};
92 }
93 
94 inline SmartStokesVectors SmartAssign(StokesVectors stokesVector) {
95  return {SmartAssign(stokesVector.S0), SmartAssign(stokesVector.S1), SmartAssign(stokesVector.S2)};
96 }
97 
98 } // namespace Itala
99 
100 #endif
Definition: DefectivePixel.h:23
Definition: IDevice.h:34
virtual void Dispose()=0
Definition: ISystem.h:34
Definition: IImage.h:30