1
/****************************************************************************
3
** This file is part of the LibreCAD project, a 2D CAD program
5
** Copyright (C) 2010 R. van Twisk (librecad@rvt.dds.nl)
6
** Copyright (C) 2001-2003 RibbonSoft. All rights reserved.
9
** This program is free software; you can redistribute it and/or modify
10
** it under the terms of the GNU General Public License as published by
11
** the Free Software Foundation; either version 2 of the License, or
12
** (at your option) any later version.
14
** This program is distributed in the hope that it will be useful,
15
** but WITHOUT ANY WARRANTY; without even the implied warranty of
16
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
** GNU General Public License for more details.
19
** You should have received a copy of the GNU General Public License
20
** along with this program; if not, write to the Free Software
21
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23
** This copyright notice MUST APPEAR in all copies of the script!
25
**********************************************************************/
28
#ifndef RS_FILTERINTERFACE_H
29
#define RS_FILTERINTERFACE_H
31
#include "rs_graphic.h"
33
#include "rs_string.h"
34
#include "rs_valuelist.h"
39
* This is the interface that must be implemented for all
40
* format filter classes. The RS_FileIO class
41
* uses the methods defined in here to interact with the format
44
* @author Andrew Mustun
46
class RS_FilterInterface {
51
RS_FilterInterface() {
52
//std::cout << "RS_FilterInterface\n";
59
virtual ~RS_FilterInterface() {}
62
* Checks if this filter can import the given file type.
64
* @retval true if the filter can import the file type
65
* @retval false otherwise.
67
virtual bool canImport(RS2::FormatType t) {
68
return !(importFormats.find(t)==importFormats.end());
72
* Checks if this filter can export the given file type.
74
* @return true if the filter can export the file type,
77
virtual bool canExport(RS2::FormatType t) {
78
return !(exportFormats.find(t)==exportFormats.end());
82
* The implementation of this method in a inherited format
83
* class should read a file from disk and put the entities
84
* into the current entity container.
86
virtual bool fileImport(RS_Graphic& g, const RS_String& file, RS2::FormatType type) = 0;
89
* The implementation of this method in a inherited format
90
* class should write the entities in the current entity container
91
* to a file on the disk.
93
virtual bool fileExport(RS_Graphic& g, const RS_String& file, RS2::FormatType type) = 0;
97
* Adds a file extension which can be imported by this filter.
99
void addImportFormat(RS2::FormatType type) {
100
RS_DEBUG->print("Filter can import %d", (int)type);
101
importFormats += type;
105
* Adds a file extension which can be exported by this filter.
107
void addExportFormat(RS2::FormatType type) {
108
RS_DEBUG->print("Filter can export %d", (int)type);
109
exportFormats += type;
113
//! Pointer to the graphic we currently operate on.
114
//RS_Graphic* graphic;
116
//! Vector of file extensions this filter can import.
117
RS_ValueList<RS2::FormatType> importFormats;
119
//! Vector of file extensions this filter can export.
120
RS_ValueList<RS2::FormatType> exportFormats;