brainrat-private 6.0.4
dpyreader.h
Go to the documentation of this file.
1/* Copyright (C) 2000-2013 CEA
2 *
3 * This software and supporting documentation were developed by
4 * bioPICSEL
5 * CEA/DSV/I²BM/MIRCen/LMN, Batiment 61,
6 * 18, route du Panorama
7 * 92265 Fontenay-aux-Roses
8 * France
9 */
10
11#ifndef BRAINRAT_PLUGINS_BIODPY_LIB_IO_DPYREADER_H
12#define BRAINRAT_PLUGINS_BIODPY_LIB_IO_DPYREADER_H
13
14#include <stdio.h>
15#include <cartobase/stream/fileutil.h>
16#include <cartobase/object/object_d.h>
17#include <cartobase/object/pythonreader.h>
18// FIXME: should not include _d.h files here
19#include <soma-io/io/formatdictionary_d.h>
20#include <soma-io/io/reader_d.h>
21#include <aims/io/reader_d.h>
25
26using namespace std;
27using namespace carto;
28
30
31namespace bio
32{
34 {
35 public:
36 DpyReader( const string& name )
37 : _name( name ) {}
39
40 void read( DpyData& thing, Object options );
41
42 private:
43 string _name;
44 };
45
46
47 DpyReader &
48 operator >> ( DpyReader & reader, DpyData& thing )
49 {
50 reader.read( thing,
51 Object::value( PropertySet() ) );
52 return reader;
53 }
54
56 Object )
57 {
58 DpyHeader *hdr = new DpyHeader( _name );
59
60 try
61 {
62 hdr->read();
63 }
64 catch( exception & e )
65 {
66 delete hdr;
67 throw;
68 }
69
70 string dir = FileUtil::dirname( _name );
71 if( !dir.empty() )
72 dir += FileUtil::separator();
73
74 vector<string> files = hdr->inputFilenames();
75 Object data;
76
77 if ( files.size() > 0 ) {
79 SyntaxSet rules = parsers.getSyntaxSet();
80 PythonReader::HelperSet helpers = parsers.getReaderHelperSet();
81 PythonReader datareader( dir + files[0], rules, helpers );
82 data.reset( datareader.read() );
83 }
84
85 thing.setHeader( *hdr );
86 thing.setContent( data );
87
88 if( hdr->hasProperty( "filenames" ) )
89 hdr->removeProperty( "filenames" );
90 }
91}
92
93#endif
The data class of the dpy format.
Definition dpydata.h:25
void setHeader(DpyHeader &header)
Definition dpydata.h:30
void setContent(Object &content)
Definition dpydata.h:33
The descriptor class of the header.
Definition dpyheader.h:28
PythonReader::HelperSet & getReaderHelperSet()
static DpyParsers & singleton()
SyntaxSet & getSyntaxSet()
void read(DpyData &thing, Object options)
Definition dpyreader.h:55
DpyReader(const string &name)
Definition dpyreader.h:36
AIMS_INSTANTIATE_READER(bio::DpyData)
ImageProcessors<AimsRGB, double> p(data, mask, "rgbm", options, ImageProcessorMode::Init); ImageProce...
Definition classes.h:25
DpyReader & operator>>(DpyReader &reader, DpyData &thing)
Definition dpyreader.h:48
STL namespace.