-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDatabase.h
executable file
·168 lines (139 loc) · 6.9 KB
/
Database.h
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
//------------------------------------------------------------------------------
/// Filename: Database.h
/// Description: Header for Class Database
/// Authors:
/// Robin Ankele(0931951)
/// Tutor: Manuel Weber
/// Group: 24
/// Created: 08.09.2011
/// Last change: 19.09.2011
//------------------------------------------------------------------------------
#ifndef DATABASE_H_INCLUDED
#define DATABASE_H_INCLUDED
#include <string>
#include <vector>
#include "SVGObject.h"
class SVGHandler;
class Database
{
private:
//----------------------------------------------------------------------------
/// SVGHandler handle
SVGHandler *svgh_;
//----------------------------------------------------------------------------
/// Config Filename
std::string filename_;
//----------------------------------------------------------------------------
/// Magic Number
std::string magic_number_;
//----------------------------------------------------------------------------
/// Width of SVGDocument
signed int width_;
//----------------------------------------------------------------------------
/// Height of SVGDocument
signed int height_;
//----------------------------------------------------------------------------
/// amount of SVGObjects in the SVGObject database
unsigned int svg_objects_counter_;
//----------------------------------------------------------------------------
/// Database of SVGObjects
std::vector<SVGObject*> svg_objects_;
//----------------------------------------------------------------------------
/// Group of SVGObjects
std::vector<SVGObject*> group_;
//----------------------------------------------------------------------------
/// Copy Constructor
/// Makes a copy of another Database Object.
/// @param source Original to copy.
Database(const Database& source);
//----------------------------------------------------------------------------
/// Assignment Operator
/// Used to assign one Database to another
/// @param source Original with values to copy.
Database &operator=(const Database& source);
public:
//----------------------------------------------------------------------------
/// Constructor
/// @param parameter contains the filename of the svg file
/// @param svhg Connection to the SVGHandler
Database(std::string parameter,
SVGHandler *svgh);
//----------------------------------------------------------------------------
/// Destructor
virtual ~Database() throw();
//----------------------------------------------------------------------------
/// getFilename() getterMethod: returns the filename of the Config File
/// @return returns the filename of the Config File
std::string getFilename() { return filename_;}
//----------------------------------------------------------------------------
/// getWidth() getterMethod: returns the width of the SVGDocument
/// @return returns the width of the SVGDocument
signed int getWidth() { return width_;}
//----------------------------------------------------------------------------
/// getHeight() getterMethod: returns the height of the SVGDocument
/// @return returns the height of the SVGDocument
signed int getHeight() { return height_;}
//----------------------------------------------------------------------------
/// checkConfigFile() Method: checks if Config File can be opened
/// @return returns true if Config File can be opened
bool checkConfigFile();
//----------------------------------------------------------------------------
/// readConfigFile() Method: checks if Config File fits
/// @return returns true if Config File fits
bool readConfigFile();
//----------------------------------------------------------------------------
/// checkMagicNumber() Method: checks the Magic Number of the Config File
/// @param content holds the magic number
/// @return returns true if Magic Number fits
bool checkMagicNumber(char *content);
//----------------------------------------------------------------------------
/// readPrompt() Method: checks and sets the Prompt
/// @param buffer is the char* where the prompt is saved
/// @return returns true if prompt fits
bool checkPrompt(char *buffer);
//----------------------------------------------------------------------------
/// setSVGDimensions() Method: reads the dimensions of the SVG File from the
/// Config File and converts to signed int
/// @param buffer the readed config file
/// @return true if Dimensions fits
bool setSVGDimensions(unsigned char *buffer);
//----------------------------------------------------------------------------
/// charToSignedInt() Method: converts char to signed ints
/// @param content is the string which should be converted
/// @return returns the result of the convertion
signed int charToSignedInt(unsigned char *content);
//----------------------------------------------------------------------------
/// readFile() Method: reads from File and checks if read was correct
/// @param buffer is the char* where the result will be saved
/// @param lenght is the size of bits which should be readed
/// @param config_file is the file handle from which should be readed
/// @return returns true if read from File fits
bool readFile(unsigned char *buffer, unsigned int lenght,
std::ifstream &config_file);
//----------------------------------------------------------------------------
/// getAllSVGObjects() getterMethod: returns the database of all SVGObjects
/// @return return returns a vector of all SVGObjects
std::vector<SVGObject*>& getAllSVGObjects() { return svg_objects_;}
//----------------------------------------------------------------------------
/// getSVGObjectByGrp() getterMethod: returns SVGObjects selected by a special
/// Group
/// @param grp_id the special group identifier of the SVGObjects
/// @return return returns SVGObjects selected by a special Group
std::vector<SVGObject*>& getSVGObjectByGrp(signed int grp_id);
//----------------------------------------------------------------------------
/// getSVGObjectByID() getterMethod: returns a SVGObject selected by ID
/// @param id the identifier of a SVGObject
/// @return return returns a SVGOBject selected by ID
SVGObject* getSVGObjectByID(signed int id);
//----------------------------------------------------------------------------
/// setSVGObject() setterMethod: inserts a SVGObject in the SVGObject database
/// @param svg_object the commited svg object which should be saved in the
/// database
/// @return returns void
void setSVGObject(SVGObject *svg_object);
//----------------------------------------------------------------------------
/// sort() Method: sorts the SVGObject database
/// @return returns void
void sort();
};
#endif //DATABASE_H_INCLUDED