Skip to content

Commit

Permalink
Add swig interface for new ACADA raw classes
Browse files Browse the repository at this point in the history
  • Loading branch information
sfegan committed Sep 9, 2024
1 parent a4c670e commit 9fff6da
Show file tree
Hide file tree
Showing 2 changed files with 148 additions and 1 deletion.
3 changes: 2 additions & 1 deletion swig/iact_data/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ set(CALIN_SWIG_FILES algorithms.i telescope_data_source.i
waveform_treatment_event_visitor.i nectarcam_ancillary_data.i)
if(CTA_CAMERASTOACTL_FOUND)
set(CALIN_SWIG_FILES ${CALIN_SWIG_FILES} raw_actl_l0_event_data_source.i
raw_actl_r1_event_data_source.i actl_event_decoder.i)
raw_actl_r1_event_data_source.i actl_event_decoder.i
raw_acada_event_data_source.i)
endif()
set(CALIN_SWIG_TARGET iact_data)

Expand Down
146 changes: 146 additions & 0 deletions swig/iact_data/raw_acada_event_data_source.i
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
/*
calin/iact_data/raw_actl_r1_event_data_source.i -- Stephen Fegan -- 2024-09-09
SWIG interface file for calin.io.raw_acada_event_data_source
Copyright 2024, Stephen Fegan <[email protected]>
Laboratoire Leprince-Ringuet, CNRS/IN2P3, Ecole Polytechnique, Institut Polytechnique de Paris
This file is part of "calin"
"calin" is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License version 2 or
later, as published by the Free Software Foundation.
"calin" 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.
*/

%module (package="calin.iact_data") raw_acada_event_data_source
%feature(autodoc,2);

%{
using std::streamoff;
#include <iact_data/telescope_data_source.hpp>
#include <iact_data/zfits_acada_data_source.hpp>
#include <iact_data/nectarcam_data_source.hpp>
#include <iact_data/lstcam_data_source.hpp>
#include <iact_data/cta_data_source.hpp>
#define SWIG_FILE_WITH_INIT
%}

%init %{
import_array();
%}

%include "calin_typemaps.i"
%include "calin_global_config.hpp"
%import "calin_global_definitions.i"

%import "google_protobuf.i"
%import "io/data_source.i"

%ignore get_next(uint64_t& seq_index_out);
%ignore get_next(uint64_t& seq_index_out, google::protobuf::Arena** arena);

namespace R1 {

class CameraEvent: public google::protobuf::Message { };
class CameraConfiguration: public google::protobuf::Message { };

}

%typemap(in, numinputs=0) R1::CameraEvent** CALIN_PROTOBUF_OUTPUT
(R1::CameraEvent* temp = nullptr) {
// typemap(in) R1::CameraEvent** CALIN_PROTOBUF_OUTPUT - raw_actl_event_data_source.i
$1 = &temp;
}

%typemap(argout) R1::CameraEvent** CALIN_PROTOBUF_OUTPUT {
// typemap(argout) R1::CameraEvent** CALIN_PROTOBUF_OUTPUT - raw_actl_event_data_source.i
%append_output(SWIG_NewPointerObj(SWIG_as_voidptr(*$1), $*1_descriptor, SWIG_POINTER_OWN));
}

%apply R1::CameraEvent** CALIN_PROTOBUF_OUTPUT {
R1::CameraEvent** event_out };
%apply uint64_t& OUTPUT { uint64_t& seq_index_out };
%apply google::protobuf::Arena** CALIN_ARENA_OUTPUT {
google::protobuf::Arena** arena_out };

%import "iact_data/telescope_data_source.i"

%template(DataSource_R1v0)
calin::io::data_source::DataSource<R1::CameraEvent>;
%template(RandomAccessDataSource_R1v0)
calin::io::data_source::RandomAccessDataSource<R1::CameraEvent>;

%newobject simple_get_next();

%extend calin::io::data_source::DataSource<R1::CameraEvent> {

R1::CameraEvent* simple_get_next()
{
uint64_t unused_seq_index = 0;
return $self->get_next(unused_seq_index);
}

#if 0
void get_next(uint64_t& seq_index_out, R1::CameraEvent** event_out,
google::protobuf::Arena** arena_out)
{
seq_index_out = 0;
*event_out = $self->get_next(seq_index_out, arena_out);
if(*event_out != nullptr and *arena_out == nullptr)
throw std::runtime_error("Memory allocation error: no Arena returned");
}
#else
void get_next(uint64_t& seq_index_out, R1::CameraEvent** event_out)
{
seq_index_out = 0;
*event_out = $self->get_next(seq_index_out);
}
#endif

}

%newobject get_run_header();

%include "iact_data/acada_data_source.hpp"

%template(ACADACameraEventDataSource_R1v0)
calin::iact_data::acada_data_source::ACADACameraEventDataSource<R1::CameraEvent>;
%template(ACADACameraEventDataSourceWithRunHeader_R1v0)
calin::iact_data::acada_data_source::ACADACameraEventDataSourceWithRunHeader<R1::CameraEvent,R1::CameraConfiguration>;
%template(ACADACameraEventRandomAccessDataSourceWithRunHeader_R1v0)
calin::iact_data::acada_data_source::ACADACameraEventRandomAccessDataSourceWithRunHeader<R1::CameraEvent,R1::CameraConfiguration>;

#include "io/chained_data_source.hpp"

%template(DataSourceOpener_R1v0)
calin::io::data_source::DataSourceOpener<
calin::iact_data::acada_data_source::ACADACameraEventRandomAccessDataSourceWithRunHeader<
R1::CameraEvent,R1::CameraConfiguration> >;

%template(BasicChainedDataSource_ACADACameraEventRandomAccessDataSourceWithRunHeader_R1v0)
calin::io::data_source::BasicChainedDataSource<
calin::iact_data::acada_data_source::ACADACameraEventRandomAccessDataSourceWithRunHeader<
R1::CameraEvent,R1::CameraConfiguration> >;

%template(BasicChainedRandomAccessDataSource_ACADACameraEventRandomAccessDataSourceWithRunHeader_R1v0)
calin::io::data_source::BasicChainedRandomAccessDataSource<
calin::iact_data::acada_data_source::ACADACameraEventRandomAccessDataSourceWithRunHeader<
R1::CameraEvent,R1::CameraConfiguration> >;

%include "iact_data/zfits_acada_data_source.hpp"

%template(ZFITSACADACameraEventDataSourceOpener_R1v0)
calin::iact_data::zfits_acada_data_source::ZFITSACADACameraEventDataSourceOpener<R1::CameraEvent,R1::CameraConfiguration>;

%template(ZFITSSingleFileACADACameraEventDataSource_R1v0)
calin::iact_data::zfits_acada_data_source::ZFITSSingleFileACADACameraEventDataSource<R1::CameraEvent,R1::CameraConfiguration>;
%template(ZFITSACADACameraEventDataSource_R1v0)
calin::iact_data::zfits_acada_data_source::ZFITSACADACameraEventDataSource<R1::CameraEvent,R1::CameraConfiguration>;

0 comments on commit 9fff6da

Please sign in to comment.