Commit a3ace6fc authored by Alejandro Homs Puron's avatar Alejandro Homs Puron Committed by Operator for ID00
Browse files

Move SlsDetector::Args to dedicated C++ header and source files

parent 5e3f28b8
//###########################################################################
// 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 __SLS_DETECTOR_ARGS_H
#define __SLS_DETECTOR_ARGS_H
#include "lima/AutoObj.h"
#include "lima/Debug.h"
#include <string>
#include <vector>
namespace lima
{
namespace SlsDetector
{
class Args
{
DEB_CLASS_NAMESPC(DebModCamera, "Args", "SlsDetector");
public:
Args();
Args(unsigned int argc, char *argv[]);
Args(const std::string& s);
Args(const Args& o);
void set(const std::string& s);
void clear();
unsigned int size()
{ return m_argc; }
operator char **()
{ return m_argv; }
operator bool()
{ return bool(m_argc); }
char *operator[](int pos)
{ return m_argv[pos]; }
Args& operator =(const std::string& s);
std::string pop_front();
void erase(int pos);
private:
typedef std::vector<std::string> StringList;
void update_argc_argv();
StringList m_arg_list;
unsigned int m_argc;
AutoPtr<char *, true> m_argv;
};
} // namespace SlsDetector
} // namespace lima
#endif // __SLS_DETECTOR_ARGS_H
......@@ -23,6 +23,8 @@
#ifndef __SLS_DETECTOR_CAMERA_H
#define __SLS_DETECTOR_CAMERA_H
#include "SlsDetectorArgs.h"
#include "multiSlsDetector.h"
#include "multiSlsDetectorCommand.h"
#include "slsReceiverUsers.h"
......@@ -50,44 +52,6 @@ namespace lima
namespace SlsDetector
{
class Args
{
DEB_CLASS_NAMESPC(DebModCamera, "Args", "SlsDetector");
public:
Args();
Args(unsigned int argc, char *argv[]);
Args(const std::string& s);
Args(const Args& o);
void set(const std::string& s);
void clear();
unsigned int size()
{ return m_argc; }
operator char **()
{ return m_argv; }
operator bool()
{ return bool(m_argc); }
char *operator[](int pos)
{ return m_argv[pos]; }
Args& operator =(const std::string& s);
string pop_front();
void erase(int pos);
private:
typedef std::vector<std::string> StringList;
void update_argc_argv();
StringList m_arg_list;
unsigned int m_argc;
AutoPtr<char *, true> m_argv;
};
class Camera : public HwMaxImageSizeCallbackGen
{
DEB_CLASS_NAMESPC(DebModCamera, "Camera", "SlsDetector");
......
......@@ -44,12 +44,12 @@ public:
};
enum TrigMode {
Auto = AUTO_TIMING,
Auto = AUTO_TIMING,
TriggerExposure = TRIGGER_EXPOSURE,
TriggerReadout = TRIGGER_READOUT,
Gating = GATE_FIX_NUMBER,
TriggerReadout = TRIGGER_READOUT,
Gating = GATE_FIX_NUMBER,
TriggeredGating = GATE_WITH_START_TRIGGER,
BurstTrigger = BURST_TRIGGER,
BurstTrigger = BURST_TRIGGER,
};
enum Settings {
......
......@@ -40,7 +40,7 @@ SLS_DETECTORS_INCL_FLAGS = -I$(SLS_DETECTORS_SW)/include \
CPPFLAGS = $(CT_CPPFLAGS) $(SLS_DETECTORS_INCL_FLAGS)
CXXFLAGS = -I../include $(CT_CXXFLAGS)
slsdetector-objs = SlsDetectorInterface.o SlsDetectorCamera.o
slsdetector-objs = SlsDetectorInterface.o SlsDetectorCamera.o SlsDetectorArgs.o
SRCS = $(slsdetector-objs:.o=.cpp)
......
//###########################################################################
// 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 "SlsDetectorArgs.h"
using namespace std;
using namespace lima;
using namespace lima::SlsDetector;
Args::Args()
{
DEB_CONSTRUCTOR();
update_argc_argv();
}
Args::Args(unsigned int argc, char *argv[])
{
DEB_CONSTRUCTOR();
for (unsigned int i = 0; i < argc; ++i)
m_arg_list.push_back(argv[i]);
update_argc_argv();
}
Args::Args(const string& s)
{
DEB_CONSTRUCTOR();
set(s);
}
Args::Args(const Args& o) : m_arg_list(o.m_arg_list)
{
DEB_CONSTRUCTOR();
update_argc_argv();
}
void Args::set(const string& s)
{
DEB_MEMBER_FUNCT();
m_arg_list.clear();
istringstream is(s);
while (is) {
string token;
is >> token;
m_arg_list.push_back(token);
}
update_argc_argv();
}
void Args::clear()
{
DEB_MEMBER_FUNCT();
m_arg_list.clear();
update_argc_argv();
}
Args& Args::operator =(const std::string& s)
{
DEB_MEMBER_FUNCT();
set(s);
return *this;
}
string Args::pop_front()
{
DEB_MEMBER_FUNCT();
string s = m_arg_list[0];
erase(0);
return s;
}
void Args::erase(int pos)
{
DEB_MEMBER_FUNCT();
m_arg_list.erase(m_arg_list.begin() + pos);
update_argc_argv();
}
void Args::update_argc_argv()
{
DEB_MEMBER_FUNCT();
m_argc = m_arg_list.size();
m_argv = new char *[m_argc + 1];
for (unsigned int i = 0; i < m_argc; ++i)
m_argv[i] = const_cast<char *>(m_arg_list[i].c_str());
m_argv[m_argc] = NULL;
}
......@@ -28,84 +28,6 @@ using namespace lima;
using namespace lima::SlsDetector;
Args::Args()
{
DEB_CONSTRUCTOR();
update_argc_argv();
}
Args::Args(unsigned int argc, char *argv[])
{
DEB_CONSTRUCTOR();
for (unsigned int i = 0; i < argc; ++i)
m_arg_list.push_back(argv[i]);
update_argc_argv();
}
Args::Args(const string& s)
{
DEB_CONSTRUCTOR();
set(s);
}
Args::Args(const Args& o) : m_arg_list(o.m_arg_list)
{
DEB_CONSTRUCTOR();
update_argc_argv();
}
void Args::set(const string& s)
{
DEB_MEMBER_FUNCT();
m_arg_list.clear();
istringstream is(s);
while (is) {
string token;
is >> token;
m_arg_list.push_back(token);
}
update_argc_argv();
}
void Args::clear()
{
DEB_MEMBER_FUNCT();
m_arg_list.clear();
update_argc_argv();
}
Args& Args::operator =(const std::string& s)
{
DEB_MEMBER_FUNCT();
set(s);
return *this;
}
string Args::pop_front()
{
DEB_MEMBER_FUNCT();
string s = m_arg_list[0];
erase(0);
return s;
}
void Args::erase(int pos)
{
DEB_MEMBER_FUNCT();
m_arg_list.erase(m_arg_list.begin() + pos);
update_argc_argv();
}
void Args::update_argc_argv()
{
DEB_MEMBER_FUNCT();
m_argc = m_arg_list.size();
m_argv = new char *[m_argc + 1];
for (unsigned int i = 0; i < m_argc; ++i)
m_argv[i] = const_cast<char *>(m_arg_list[i].c_str());
m_argv[m_argc] = NULL;
}
Camera::Model::Model(Camera *cam, Type type)
: m_cam(cam), m_type(type)
{
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment