brainrat-private 6.0.4
dpywriter.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_DPYWRITER_H
12#define BRAINRAT_PLUGINS_BIODPY_LIB_IO_DPYWRITER_H
13
14#include <cartobase/object/object_d.h>
15#include <cartobase/object/pythonwriter.h>
16// FIXME: should not include _d.h files here.
17#include <soma-io/io/writer_d.h>
18#include <aims/io/writer_d.h>
22
23using namespace std;
24using namespace carto;
25using namespace aims;
26
28
29namespace bio
30{
31
33 {
34 public:
35 DpyWriter( const string& name )
36 : _name( name ) {}
38
39 void write( const DpyData& thing );
40
41 private:
42 string _name;
43 };
44
46 operator << ( DpyWriter & writer, const DpyData& thing )
47 {
48 writer.write( thing );
49 return writer;
50 }
51
52
53 void DpyWriter::write( const DpyData& thing )
54 {
55 DpyHeader hdr = thing.header();
56 hdr.setName( _name );
57
58 string dir = FileUtil::dirname( _name );
59 vector<string> files = hdr.outputFilenames();
60
61 hdr.setProperty( "file_type", string( "DPY" ) );
62 hdr.setProperty( "filenames", files );
63 if( !dir.empty() )
64 dir += carto::FileUtil::separator();
65
66 if ( files.size() > 0 ) {
68 SyntaxSet rules = parsers.getSyntaxSet();
69 PythonWriter::HelperSet helpers = parsers.getWriterHelperSet();
70 PythonWriter datawriter( dir + files[0], rules, helpers );
71 datawriter.write( thing.content() );
72
73 }
74
75 hdr.writeMinf( dir + carto::FileUtil::removeExtension( files[0] )
76 + hdr.extension() + ".minf" );
77 }
78}
79
80#endif
81
The data class of the dpy format.
Definition dpydata.h:25
Object & content()
Definition dpydata.h:34
DpyHeader header() const
Definition dpydata.h:31
The descriptor class of the header.
Definition dpyheader.h:28
virtual string extension() const
Definition dpyheader.h:57
void setName(string name)
Definition dpyheader.h:54
PythonWriter::HelperSet & getWriterHelperSet()
static DpyParsers & singleton()
SyntaxSet & getSyntaxSet()
DpyWriter(const string &name)
Definition dpywriter.h:35
void write(const DpyData &thing)
Definition dpywriter.h:53
AIMS_INSTANTIATE_WRITER(bio::DpyData)
ImageProcessors<AimsRGB, double> p(data, mask, "rgbm", options, ImageProcessorMode::Init); ImageProce...
Definition classes.h:25
std::ostream & operator<<(std::ostream &os, const bio::BVclass &thing)
STL namespace.