New Feature: load/save lima configuration

parent e03c705f
...@@ -82,3 +82,6 @@ ...@@ -82,3 +82,6 @@
[submodule "camera/andor3"] [submodule "camera/andor3"]
path = camera/andor3 path = camera/andor3
url = git://github.com/esrf-bliss/Lima-camera-andor3.git url = git://github.com/esrf-bliss/Lima-camera-andor3.git
[submodule "third-party/libconfig"]
path = third-party/libconfig
url = git://github.com/esrf-bliss/libconfig.git
...@@ -56,7 +56,7 @@ create-links = \ ...@@ -56,7 +56,7 @@ create-links = \
# LIMA - CORE # LIMA - CORE
############################ ############################
CORE_LDFLAGS := -L../third-party/Processlib/build CORE_LDFLAGS := -L../third-party/Processlib/build -Wl,-rpath=$(shell pwd)/../third-party/Processlib/build
CORE_LDLIBS := -lprocesslib -lrt CORE_LDLIBS := -lprocesslib -lrt
ifneq ($(COMPILE_CBF_SAVING),0) ifneq ($(COMPILE_CBF_SAVING),0)
...@@ -73,6 +73,10 @@ ifneq ($(COMPILE_EDFGZ_SAVING),0) ...@@ -73,6 +73,10 @@ ifneq ($(COMPILE_EDFGZ_SAVING),0)
CORE_LDLIBS += -lz CORE_LDLIBS += -lz
endif endif
ifneq ($(COMPILE_CONFIG),0)
CORE_LDLIBS += -L../third-party/libconfig/lib/.libs -Wl,-rpath=$(shell pwd)/../third-party/libconfig/lib/.libs -lconfig++
endif
ifneq ($(COMPILE_CORE),0) ifneq ($(COMPILE_CORE),0)
core-name := core core-name := core
......
...@@ -3,14 +3,19 @@ Microsoft Visual Studio Solution File, Format Version 10.00 ...@@ -3,14 +3,19 @@ Microsoft Visual Studio Solution File, Format Version 10.00
# Visual C++ Express 2008 # Visual C++ Express 2008
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "LibSimulator", "LibSimulator.vcproj", "{3E1490E7-66C0-4E77-9746-0632466FF270}" Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "LibSimulator", "LibSimulator.vcproj", "{3E1490E7-66C0-4E77-9746-0632466FF270}"
ProjectSection(ProjectDependencies) = postProject ProjectSection(ProjectDependencies) = postProject
{F6556656-D091-43AF-B46F-355F4ABA5DB6} = {F6556656-D091-43AF-B46F-355F4ABA5DB6}
{A4B703A6-C50F-442F-8952-54FB8EA51FF3} = {A4B703A6-C50F-442F-8952-54FB8EA51FF3} {A4B703A6-C50F-442F-8952-54FB8EA51FF3} = {A4B703A6-C50F-442F-8952-54FB8EA51FF3}
EndProjectSection EndProjectSection
EndProject EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "LibLimaCore", "..\LimaCore\LimaCore.vcproj", "{A4B703A6-C50F-442F-8952-54FB8EA51FF3}" Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "LibLimaCore", "..\LimaCore\LimaCore.vcproj", "{A4B703A6-C50F-442F-8952-54FB8EA51FF3}"
ProjectSection(ProjectDependencies) = postProject
{F6556656-D091-43AF-B46F-355F4ABA5DB6} = {F6556656-D091-43AF-B46F-355F4ABA5DB6}
{1A234565-926D-49B2-83E4-D56E0C38C9F2} = {1A234565-926D-49B2-83E4-D56E0C38C9F2}
EndProjectSection
EndProject EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libprocesslib", "..\..\..\..\third-party\Processlib\build\msvc\9.0\libprocesslib\libprocesslib.vcproj", "{F6556656-D091-43AF-B46F-355F4ABA5DB6}" Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libprocesslib", "..\..\..\..\third-party\Processlib\build\msvc\9.0\libprocesslib\libprocesslib.vcproj", "{F6556656-D091-43AF-B46F-355F4ABA5DB6}"
EndProject EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libconfig", "..\..\..\..\third-party\libconfig\lib\libconfig.vcproj", "{1A234565-926D-49B2-83E4-D56E0C38C9F2}"
EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32 Debug|Win32 = Debug|Win32
...@@ -29,6 +34,10 @@ Global ...@@ -29,6 +34,10 @@ Global
{F6556656-D091-43AF-B46F-355F4ABA5DB6}.Debug|Win32.Build.0 = Debug|Win32 {F6556656-D091-43AF-B46F-355F4ABA5DB6}.Debug|Win32.Build.0 = Debug|Win32
{F6556656-D091-43AF-B46F-355F4ABA5DB6}.Release|Win32.ActiveCfg = Release|Win32 {F6556656-D091-43AF-B46F-355F4ABA5DB6}.Release|Win32.ActiveCfg = Release|Win32
{F6556656-D091-43AF-B46F-355F4ABA5DB6}.Release|Win32.Build.0 = Release|Win32 {F6556656-D091-43AF-B46F-355F4ABA5DB6}.Release|Win32.Build.0 = Release|Win32
{1A234565-926D-49B2-83E4-D56E0C38C9F2}.Debug|Win32.ActiveCfg = Debug|Win32
{1A234565-926D-49B2-83E4-D56E0C38C9F2}.Debug|Win32.Build.0 = Debug|Win32
{1A234565-926D-49B2-83E4-D56E0C38C9F2}.Release|Win32.ActiveCfg = Release|Win32
{1A234565-926D-49B2-83E4-D56E0C38C9F2}.Release|Win32.Build.0 = Release|Win32
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE
......
...@@ -178,6 +178,14 @@ ...@@ -178,6 +178,14 @@
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx" Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}" UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
> >
<File
RelativePath="..\..\..\..\camera\simulator\src\SimulatorCamera.cpp"
>
</File>
<File
RelativePath="..\..\..\..\camera\simulator\src\SimulatorDetInfoCtrlObj.cpp"
>
</File>
<File <File
RelativePath="..\..\..\..\camera\simulator\src\SimulatorFrameBuilder.cpp" RelativePath="..\..\..\..\camera\simulator\src\SimulatorFrameBuilder.cpp"
> >
...@@ -187,7 +195,7 @@ ...@@ -187,7 +195,7 @@
> >
</File> </File>
<File <File
RelativePath="..\..\..\..\camera\simulator\src\SimulatorCamera.cpp" RelativePath="..\..\..\..\camera\simulator\src\SimulatorSyncCtrlObj.cpp"
> >
</File> </File>
</Filter> </Filter>
...@@ -197,15 +205,15 @@ ...@@ -197,15 +205,15 @@
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}" UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
> >
<File <File
RelativePath="..\..\..\..\camera\simulator\include\SimulatorFrameBuilder.h" RelativePath="..\..\..\..\camera\simulator\include\SimulatorCamera.h"
> >
</File> </File>
<File <File
RelativePath="..\..\..\..\camera\simulator\include\SimulatorInterface.h" RelativePath="..\..\..\..\camera\simulator\include\SimulatorFrameBuilder.h"
> >
</File> </File>
<File <File
RelativePath="..\..\..\..\camera\simulator\include\SimulatorCamera.h" RelativePath="..\..\..\..\camera\simulator\include\SimulatorInterface.h"
> >
</File> </File>
</Filter> </Filter>
......
...@@ -4,10 +4,13 @@ Microsoft Visual Studio Solution File, Format Version 10.00 ...@@ -4,10 +4,13 @@ Microsoft Visual Studio Solution File, Format Version 10.00
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "LibLimaCore", "LimaCore.vcproj", "{A4B703A6-C50F-442F-8952-54FB8EA51FF3}" Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "LibLimaCore", "LimaCore.vcproj", "{A4B703A6-C50F-442F-8952-54FB8EA51FF3}"
ProjectSection(ProjectDependencies) = postProject ProjectSection(ProjectDependencies) = postProject
{F6556656-D091-43AF-B46F-355F4ABA5DB6} = {F6556656-D091-43AF-B46F-355F4ABA5DB6} {F6556656-D091-43AF-B46F-355F4ABA5DB6} = {F6556656-D091-43AF-B46F-355F4ABA5DB6}
{A0C36CE7-D908-4573-8B69-249EEEB7D2BE} = {A0C36CE7-D908-4573-8B69-249EEEB7D2BE}
EndProjectSection EndProjectSection
EndProject EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libprocesslib", "..\..\..\..\third-party\Processlib\build\msvc\9.0\libprocesslib\libprocesslib.vcproj", "{F6556656-D091-43AF-B46F-355F4ABA5DB6}" Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libprocesslib", "..\..\..\..\third-party\Processlib\build\msvc\9.0\libprocesslib\libprocesslib.vcproj", "{F6556656-D091-43AF-B46F-355F4ABA5DB6}"
EndProject EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libconfig++", "..\..\..\..\third-party\libconfig\lib\libconfig++.vcproj", "{A0C36CE7-D908-4573-8B69-249EEEB7D2BE}"
EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32 Debug|Win32 = Debug|Win32
...@@ -22,6 +25,10 @@ Global ...@@ -22,6 +25,10 @@ Global
{F6556656-D091-43AF-B46F-355F4ABA5DB6}.Debug|Win32.Build.0 = Debug|Win32 {F6556656-D091-43AF-B46F-355F4ABA5DB6}.Debug|Win32.Build.0 = Debug|Win32
{F6556656-D091-43AF-B46F-355F4ABA5DB6}.Release|Win32.ActiveCfg = Release|Win32 {F6556656-D091-43AF-B46F-355F4ABA5DB6}.Release|Win32.ActiveCfg = Release|Win32
{F6556656-D091-43AF-B46F-355F4ABA5DB6}.Release|Win32.Build.0 = Release|Win32 {F6556656-D091-43AF-B46F-355F4ABA5DB6}.Release|Win32.Build.0 = Release|Win32
{A0C36CE7-D908-4573-8B69-249EEEB7D2BE}.Debug|Win32.ActiveCfg = Debug|Win32
{A0C36CE7-D908-4573-8B69-249EEEB7D2BE}.Debug|Win32.Build.0 = Debug|Win32
{A0C36CE7-D908-4573-8B69-249EEEB7D2BE}.Release|Win32.ActiveCfg = Release|Win32
{A0C36CE7-D908-4573-8B69-249EEEB7D2BE}.Release|Win32.Build.0 = Release|Win32
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE
......
...@@ -42,8 +42,8 @@ ...@@ -42,8 +42,8 @@
<Tool <Tool
Name="VCCLCompilerTool" Name="VCCLCompilerTool"
Optimization="0" Optimization="0"
AdditionalIncludeDirectories="..\..\..\..\control\src;&quot;..\..\..\..\third-party\Processlib\tasks\include&quot;;&quot;..\..\..\..\third-party\Processlib\core\include\WindowSpecific&quot;;&quot;..\..\..\..\third-party\Processlib\core\include&quot;;..\..\..\..\control\software_operation\include;..\..\..\..\control\include;..\..\..\..\hardware\include;..\..\..\..\common\include" AdditionalIncludeDirectories="..\..\..\..\control\src;&quot;..\..\..\..\third-party\Processlib\tasks\include&quot;;&quot;..\..\..\..\third-party\Processlib\core\include\WindowSpecific&quot;;&quot;..\..\..\..\third-party\Processlib\core\include&quot;;..\..\..\..\control\software_operation\include;..\..\..\..\control\include;..\..\..\..\hardware\include;..\..\..\..\common\include;&quot;..\..\..\..\third-party\libconfig\lib&quot;"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;LIMACORE_EXPORTS;_WIN32_WINNT=0x0502" PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;LIMACORE_EXPORTS;_WIN32_WINNT=0x0502;WITH_CONFIG"
MinimalRebuild="true" MinimalRebuild="true"
BasicRuntimeChecks="0" BasicRuntimeChecks="0"
RuntimeLibrary="2" RuntimeLibrary="2"
...@@ -65,7 +65,7 @@ ...@@ -65,7 +65,7 @@
/> />
<Tool <Tool
Name="VCLinkerTool" Name="VCLinkerTool"
AdditionalDependencies="$(InputDir)..\..\..\..\third-party\Processlib\build\msvc\9.0\libprocesslib\Debug\libprocesslib.lib" AdditionalDependencies="$(InputDir)..\..\..\..\third-party\Processlib\build\msvc\9.0\libprocesslib\Debug\libprocesslib.lib $(InputDir)..\..\..\..\third-party\libconfig\lib\libconfig++.Debug\libconfig++_d.lib"
OutputFile="$(InputDir)$(IntDir)\$(ProjectName).dll" OutputFile="$(InputDir)$(IntDir)\$(ProjectName).dll"
LinkIncremental="2" LinkIncremental="2"
AdditionalLibraryDirectories="&quot;..\..\..\..\third-party\Processlib\build\msvc\9.0\libprocesslib\Debug&quot;" AdditionalLibraryDirectories="&quot;..\..\..\..\third-party\Processlib\build\msvc\9.0\libprocesslib\Debug&quot;"
...@@ -123,8 +123,8 @@ ...@@ -123,8 +123,8 @@
Name="VCCLCompilerTool" Name="VCCLCompilerTool"
Optimization="2" Optimization="2"
EnableIntrinsicFunctions="true" EnableIntrinsicFunctions="true"
AdditionalIncludeDirectories="..\..\..\..\control\src;&quot;..\..\..\..\third-party\Processlib\tasks\include&quot;;&quot;..\..\..\..\third-party\Processlib\core\include\WindowSpecific&quot;;&quot;..\..\..\..\third-party\Processlib\core\include&quot;;..\..\..\..\control\software_operation\include;..\..\..\..\control\include;..\..\..\..\hardware\include;..\..\..\..\common\include" AdditionalIncludeDirectories="..\..\..\..\control\src;&quot;..\..\..\..\third-party\Processlib\tasks\include&quot;;&quot;..\..\..\..\third-party\Processlib\core\include\WindowSpecific&quot;;&quot;..\..\..\..\third-party\Processlib\core\include&quot;;..\..\..\..\control\software_operation\include;..\..\..\..\control\include;..\..\..\..\hardware\include;..\..\..\..\common\include;&quot;..\..\..\..\third-party\libconfig\lib&quot;"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;LIMACORE_EXPORTS;_WIN32_WINNT=0x0502" PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;LIMACORE_EXPORTS;_WIN32_WINNT=0x0502;WITH_CONFIG"
RuntimeLibrary="2" RuntimeLibrary="2"
EnableFunctionLevelLinking="true" EnableFunctionLevelLinking="true"
UsePrecompiledHeader="0" UsePrecompiledHeader="0"
...@@ -145,10 +145,10 @@ ...@@ -145,10 +145,10 @@
/> />
<Tool <Tool
Name="VCLinkerTool" Name="VCLinkerTool"
AdditionalDependencies="$(InputDir)..\..\..\..\third-party\Processlib\build\msvc\9.0\libprocesslib\Release\libprocesslib.lib" AdditionalDependencies="$(InputDir)..\..\..\..\third-party\Processlib\build\msvc\9.0\libprocesslib\Release\libprocesslib.lib $(InputDir)..\..\..\..\third-party\libconfig\lib\libconfig++.Release\libconfig++.lib"
OutputFile="$(InputDir)$(IntDir)\$(ProjectName).dll" OutputFile="$(InputDir)$(IntDir)\$(ProjectName).dll"
LinkIncremental="1" LinkIncremental="1"
AdditionalLibraryDirectories="&quot;..\..\..\..\third-party\Processlib\build\msvc\9.0\libprocesslib\Release&quot;" AdditionalLibraryDirectories="&quot;..\..\..\..\third-party\Processlib\build\msvc\9.0\libprocesslib\Release&quot;;&quot;..\..\..\..\third-party\libconfig\lib\libconfig++.Release&quot;"
GenerateDebugInformation="true" GenerateDebugInformation="true"
GenerateMapFile="true" GenerateMapFile="true"
MapExports="true" MapExports="true"
...@@ -192,6 +192,10 @@ ...@@ -192,6 +192,10 @@
RelativePath="..\..\..\..\common\src\AcqState.cpp" RelativePath="..\..\..\..\common\src\AcqState.cpp"
> >
</File> </File>
<File
RelativePath="..\..\..\..\common\src\ConfigUtils.cpp"
>
</File>
<File <File
RelativePath="..\..\..\..\common\src\Constants.cpp" RelativePath="..\..\..\..\common\src\Constants.cpp"
> >
...@@ -208,6 +212,10 @@ ...@@ -208,6 +212,10 @@
RelativePath="..\..\..\..\control\src\CtBuffer.cpp" RelativePath="..\..\..\..\control\src\CtBuffer.cpp"
> >
</File> </File>
<File
RelativePath="..\..\..\..\control\src\CtConfig.cpp"
>
</File>
<File <File
RelativePath="..\..\..\..\control\src\CtControl.cpp" RelativePath="..\..\..\..\control\src\CtControl.cpp"
> >
...@@ -397,6 +405,10 @@ ...@@ -397,6 +405,10 @@
RelativePath="..\..\..\..\control\include\CtBuffer.h" RelativePath="..\..\..\..\control\include\CtBuffer.h"
> >
</File> </File>
<File
RelativePath="..\..\..\..\control\include\CtConfig.h"
>
</File>
<File <File
RelativePath="..\..\..\..\control\include\CtControl.h" RelativePath="..\..\..\..\control\include\CtControl.h"
> >
...@@ -453,6 +465,10 @@ ...@@ -453,6 +465,10 @@
RelativePath="..\..\..\..\hardware\include\HwCap.h" RelativePath="..\..\..\..\hardware\include\HwCap.h"
> >
</File> </File>
<File
RelativePath="..\..\..\..\hardware\include\HwConfigCtrlObj.h"
>
</File>
<File <File
RelativePath="..\..\..\..\hardware\include\HwDetInfoCtrlObj.h" RelativePath="..\..\..\..\hardware\include\HwDetInfoCtrlObj.h"
> >
......
...@@ -20,28 +20,27 @@ ...@@ -20,28 +20,27 @@
# along with this program; if not, see <http://www.gnu.org/licenses/>. # along with this program; if not, see <http://www.gnu.org/licenses/>.
############################################################################ ############################################################################
std-objs = ../../../common/src/Common.o ../../../hardware/src/Hw.o
simu-objs = ../src/Simu.o simu-objs = ../src/Simu.o
test-objs = test.o test-objs = test.o
test-ext-objs = $(simu-objs) test-ext-objs = $(simu-objs)
testsimulator-objs = testsimulator.o testsimulator-objs = testsimulator.o
testsimulator-ext-objs = $(simu-objs) $(std-objs) testsimulator-ext-objs = $(simu-objs)
testsimuhwinterface-objs = testsimuhwinterface.o testsimuhwinterface-objs = testsimuhwinterface.o
testsimuhwinterface-ext-objs = $(simu-objs) $(std-objs) testsimuhwinterface-ext-objs = $(simu-objs)
SRCS = $(test-objs:.o=.cpp) $(testsimulator-objs:.o=.cpp) \ SRCS = $(test-objs:.o=.cpp) $(testsimulator-objs:.o=.cpp) \
$(testsimuhwinterface-objs:.o=.cpp) $(testsimuhwinterface-objs:.o=.cpp)
INC = -I../include -I../../../common/include -I../../../hardware/include -I../../../third-party/Processlib/core/include INC = -I../include -I../../../common/include -I../../../hardware/include -I../../../third-party/Processlib/core/include
CXXFLAGS += $(INC) -Wall -pthread -g CXXFLAGS += $(INC) -Wall -pthread -g
LDFLAGS = -L../../../third-party/Processlib/build -lprocesslib -pthread -lrt LDFLAGS = -L../../../third-party/Processlib/build -lprocesslib -L../../../build -llimacore -pthread -lrt
all: test testsimulator testsimuhwinterface all: test testsimulator testsimuhwinterface
test: $(test-objs) $(test-ext-objs) $(std-objs) test: $(test-objs) $(test-ext-objs)
$(CXX) -o $@ $+ $(LDFLAGS) $(CXX) -o $@ $+ $(LDFLAGS)
testsimulator: $(testsimulator-objs) $(testsimulator-ext-objs) testsimulator: $(testsimulator-objs) $(testsimulator-ext-objs)
......
//###########################################################################
// This file is part of LImA, a Library for Image Acquisition
//
// Copyright (C) : 2009-2011
// European Synchrotron Radiation Facility
// BP 220, Grenoble 38043
// FRANCE
//
// This is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3 of the License, or
// (at your option) any later version.
//
// This software is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, see <http://www.gnu.org/licenses/>.
//###########################################################################
#ifndef CONFIGUTILS_H
#define CONFIGUTILS_H
#include "Debug.h"
#include "LimaCompatibility.h"
namespace libconfig
{
class Setting;
}
namespace lima
{
class LIMACORE_API Setting
{
DEB_CLASS_NAMESPC(DebModCommon,"Setting","Common");
public:
Setting(libconfig::Setting* setting = NULL) : m_setting(setting) {}
// --- lookup
bool get(const char* alias,bool& value) const;
bool get(const char* alias,int& value) const;
bool get(const char* alias,long& value) const;
bool get(const char* alias,long long& value) const;
bool get(const char* alias,double& value) const;
bool get(const char* alias,const char*& value) const;
bool get(const char* alias,std::string &value) const;
// --- modifiers
void set(const char* alias,bool value);
void set(const char* alias,int value);
void set(const char* alias,long value);
void set(const char* alias,long long value);
void set(const char* alias,double value);
void set(const char* alias,const char* value);
void set(const char* alias,const std::string &value);
// --- child
Setting addChild(const char* alias);
bool getChild(const char* alias,Setting& child) const;
const libconfig::Setting* get_raw_setting() const {return m_setting;}
private:
libconfig::Setting* m_setting;
};
}
#endif
...@@ -44,13 +44,15 @@ enum ImageType { ...@@ -44,13 +44,15 @@ enum ImageType {
}; };
LIMACORE_API std::ostream& operator <<(std::ostream& os, ImageType image_type); LIMACORE_API std::ostream& operator <<(std::ostream& os, ImageType image_type);
LIMACORE_API const char* convert_2_string(ImageType image_type);
LIMACORE_API void convert_from_string(const std::string&,ImageType&);
enum AcqMode { enum AcqMode {
Single, Concatenation, Accumulation, Single, Concatenation, Accumulation,
}; };
LIMACORE_API std::ostream& operator <<(std::ostream& os, AcqMode acq_mode); LIMACORE_API std::ostream& operator <<(std::ostream& os, AcqMode acq_mode);
LIMACORE_API const char* convert_2_string(AcqMode mode);
LIMACORE_API void convert_from_string(const std::string&,AcqMode&);
enum TrigMode { enum TrigMode {
IntTrig,IntTrigMult, IntTrig,IntTrigMult,
ExtTrigSingle, ExtTrigMult, ExtTrigSingle, ExtTrigMult,
...@@ -58,7 +60,8 @@ enum TrigMode { ...@@ -58,7 +60,8 @@ enum TrigMode {
}; };
LIMACORE_API std::ostream& operator <<(std::ostream& os, TrigMode trig_mode); LIMACORE_API std::ostream& operator <<(std::ostream& os, TrigMode trig_mode);
LIMACORE_API const char* convert_2_string(TrigMode trigMode);
LIMACORE_API void convert_from_string(const std::string&,TrigMode&);
enum BufferMode { enum BufferMode {
Linear, Circular, Linear, Circular,
}; };
...@@ -72,7 +75,8 @@ enum ShutterMode { ...@@ -72,7 +75,8 @@ enum ShutterMode {
typedef std::vector<ShutterMode> ShutterModeList; typedef std::vector<ShutterMode> ShutterModeList;
LIMACORE_API std::ostream& operator <<(std::ostream& os, ShutterMode shutter_mode); LIMACORE_API std::ostream& operator <<(std::ostream& os, ShutterMode shutter_mode);
LIMACORE_API const char* convert_2_string(ShutterMode);
LIMACORE_API void convert_from_string(const std::string&,ShutterMode&);
enum AcqStatus { enum AcqStatus {
AcqReady, AcqRunning, AcqFault, AcqConfig AcqReady, AcqRunning, AcqFault, AcqConfig
}; };
...@@ -104,7 +108,8 @@ enum VideoMode {Y8,Y16,Y32,Y64, ...@@ -104,7 +108,8 @@ enum VideoMode {Y8,Y16,Y32,Y64,
I420,YUV411,YUV422,YUV444}; I420,YUV411,YUV422,YUV444};
LIMACORE_API std::ostream& operator <<(std::ostream& os,VideoMode videoMode); LIMACORE_API std::ostream& operator <<(std::ostream& os,VideoMode videoMode);
LIMACORE_API const char* convert_2_string(VideoMode);
LIMACORE_API void convert_from_string(const std::string&,VideoMode&);
enum RotationMode { enum RotationMode {
Rotation_0, Rotation_0,
Rotation_90, Rotation_90,
...@@ -113,6 +118,8 @@ enum RotationMode { ...@@ -113,6 +118,8 @@ enum RotationMode {
}; };
LIMACORE_API std::ostream& operator <<(std::ostream& os,RotationMode rotationMode); LIMACORE_API std::ostream& operator <<(std::ostream& os,RotationMode rotationMode);
LIMACORE_API const char* convert_2_string(RotationMode rotationMode);
LIMACORE_API void convert_from_string(const std::string&,RotationMode&);
} // namespace lima } // namespace lima
#endif // CONSTANTS_H #endif // CONSTANTS_H
//###########################################################################
// This file is part of LImA, a Library for Image Acquisition
//
// Copyright (C) : 2009-2011
// European Synchrotron Radiation Facility
// BP 220, Grenoble 38043
// FRANCE
//
// This is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3 of the License, or
// (at your option) any later version.
//
// This software is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, see <http://www.gnu.org/licenses/>.
//###########################################################################
#include <libconfig.h++>
#include "Exceptions.h"
#include "ConfigUtils.h"
using namespace lima;
bool Setting::get(const char* alias,bool& value) const
{
return m_setting->lookupValue(alias,value);
}
bool Setting::get(const char* alias,int& value) const
{
return m_setting->lookupValue(alias,value);
}
bool Setting::get(const char* alias,long& value) const
{
long long tmpValue;
bool rFlag = m_setting->lookupValue(alias,tmpValue);
if(rFlag) value = long(tmpValue);
return rFlag;
}
bool Setting::get(const char* alias,long long& value) const
{
return m_setting->lookupValue(alias,value);
}
bool Setting::get(const char* alias,double& value) const
{
return m_setting->lookupValue(alias,value);
}
bool Setting::get(const char* alias,const char*& value) const
{
return m_setting->lookupValue(alias,value);
}
bool Setting::get(const char* alias,std::string& value) const
{
return m_setting->lookupValue(alias,value);
}
// --- modifiers
#define SET_VALUE(Type) \
if(m_setting->exists(alias)) \
m_setting->operator[](alias) = value; \
else \
{ \
libconfig::Setting& nSetting = m_setting->add(alias,Type); \
nSetting = value; \
}
void Setting::set(const char* alias,bool value)
{
SET_VALUE(libconfig::Setting::TypeBoolean);
}
void Setting::set(const char* alias,int value)
{
SET_VALUE(libconfig::Setting::TypeInt);
}
void Setting::set(const char* alias,long value)
{
SET_VALUE(libconfig::Setting::TypeInt64);
}
void Setting::set(const char* alias,long long value)
{
SET_VALUE(libconfig::Setting::TypeInt64);
}
void Setting::set(const char* alias,double value)
{
SET_VALUE(libconfig::Setting::TypeFloat);
}
void Setting::set(const char* alias,const char* value)
{
SET_VALUE(libconfig::Setting::TypeString);
}
void Setting::set(const char* alias,
const std::string &value)
{
SET_VALUE(libconfig::Setting::TypeString);
}
// --- child management
Setting Setting::addChild(const char *alias)
{
DEB_MEMBER_FUNCT();
try
{
libconfig::Setting &alias_setting = m_setting->add(alias,libconfig::Setting::TypeGroup);
return Setting(&alias_setting);
}
catch(libconfig::SettingNameException& exp)
{
THROW_COM_ERROR(Error) << exp.what();
}
catch(libconfig::SettingTypeException& exp)
{
THROW_COM_ERROR(Error) << exp.what();
}