blob: b4df4fad1b914773ece55188305d2cbc1b457dcd (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
|
/*
**************************************************************************
description
--------------------
copyright : (C) 2003 by Andreas Zehender
email : [email protected]
**************************************************************************
**************************************************************************
* *
* This program 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 2 of the License, or *
* (at your option) any later version. *
* *
**************************************************************************/
#ifndef PMIOMANAGER
#define PMIOMANAGER
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <tqstring.h>
#include <tqstringlist.h>
#include <tqptrlist.h>
#include <tqdict.h>
class PMParser;
class PMSerializer;
class PMRenderer;
class PMPart;
class TQIODevice;
/**
* Description class for input and output formats.
*
* A format may provide the following services:
*
* Import: The class can provide a parser to load and import data
*
* Export: The class can provide a output device to export and save data
*
* Renderer: A renderer exists to render the exported data
*
* The class @ref PMIOManager stores a list of instances
* of this class
*/
class PMIOFormat
{
public:
/**
* Format type enum
*/
enum Services { Import = 1, Export = 2, Renderer = 4,
AllServices = Import | Export | Renderer };
/**
* Default constructor
*/
PMIOFormat( );
/**
* Destructor
*/
virtual ~PMIOFormat( );
/**
* Returns an unique name of this format.
*/
virtual TQString name( ) const = 0;
/**
* Returns a translated description of this format
*/
virtual TQString description( ) const = 0;
/**
* Returns the supported services
* (a bitwise combination of the Services enum values)
*/
virtual int services( ) const = 0;
/**
* Returns a parser to parse the io device.
*
* The caller is responsible to delete the returned parser.
*/
virtual PMParser* newParser( PMPart*, TQIODevice* ) const
{
return 0;
};
/**
* Returns a parser to parse the byte array.
*
* The caller is responsible to delete the returned parser.
*/
virtual PMParser* newParser( PMPart*, const TQByteArray& ) const
{
return 0;
};
/**
* Returns an output device to export objects or the complete
* scene to the given io device.
*
* The caller is responsible to delete the returned device
*/
virtual PMSerializer* newSerializer( TQIODevice* )
{
return 0;
}
/**
* Returns a new renderer
*/
virtual PMRenderer* newRenderer( PMPart* ) const
{
return 0;
}
/**
* Returns the mime type for this format
*/
virtual TQString mimeType( ) const
{
return TQString();
}
/**
* Returns a list of patterns for the import file dialog
*/
virtual TQStringList importPatterns( ) const
{
return TQStringList( );
}
/**
* Returns a list of patterns for the export file dialog
*/
virtual TQStringList exportPatterns( ) const
{
return TQStringList( );
}
};
/**
* Manager class that handles all available input and output formats
* as well as renderers for one part
*/
class PMIOManager
{
public:
/**
* Creates an io manager for the part
*/
PMIOManager( PMPart* part );
/**
* Deletes the io manager
*/
~PMIOManager( );
/**
* Adds a new format
*/
void addFormat( PMIOFormat* format );
/**
* Removes a format by name
*/
void removeFormat( const TQString& name );
/**
* Returns the list of registered io formats
*/
const TQPtrList<PMIOFormat>& formats( ) const { return m_formats; }
/**
* Returns a view type by name
*/
PMIOFormat* format( const TQString& name ) const;
/**
* Returns the first io format that can handle the mime type
* or 0 if there is none
*/
PMIOFormat* formatForMimeType( const TQString& mime ) const;
private:
TQPtrList<PMIOFormat> m_formats;
TQDict<PMIOFormat> m_dict;
PMPart* m_pPart;
};
#endif
|