File: DictObjFile.h

package info (click to toggle)
librcsb-core-wrapper 1.005-13
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 16,576 kB
  • sloc: xml: 122,915; cpp: 25,250; ansic: 3,736; makefile: 1,033; sh: 772; lex: 294; yacc: 235; perl: 213; python: 121; csh: 30
file content (223 lines) | stat: -rw-r--r-- 5,597 bytes parent folder | download | duplicates (6)
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
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
/*$$FILE$$*/
/*$$VERSION$$*/
/*$$DATE$$*/
/*$$LICENSE$$*/


/*!
** \file DictObjFile.h
**
** \brief Header file for DictObjFile class.
*/


#ifndef DICTOBJFILE_H
#define DICTOBJFILE_H


#include "mapped_ptr_vector.h"
#include "mapped_ptr_vector.C"

#include "DictObjCont.h"

#include "DicFile.h"


/**
**  \class DictObjFile
**
**  \brief Public class that represents a dictionary object file.
**
**  This class represents a dictionary object file. This file is a container
**  of dictionary objects. Each dictionary object is a container of its
**  attributes and of objects of type: item, sub-category and category. Each
**  of those objects is a container of relevant attributes for that object
**  type. This class provides methods for construction/destruction, building
**  the dictionary object file from a dictionary, writing/reading dictionary
**  object file to/from the persistent storage file, accessing the
**  dictionaries and printing the content of the dictionary object file.
*/
class DictObjFile
{
  public:

    /**
    **  Constructs a dictionary object file.
    **
    **  \param[in] persStoreFileName - relative or absolute name of the
    **    persistent storage file
    **  \param[in] fileMode - optional parameter that indicates the dictionary
    **    object file mode. Possible values are read-only and create. Default
    **    is read mode.
    **  \param[in] verbose - optional parameter that indicates whether
    **    logging should be turned on (if true) or off (if false).
    **    If \e verbose is not specified, logging is turned off.
    **  \param[in] dictSdbFileName - optional parameter that indicates relative
    **    or absolute name of the SDB dictionary file. Must be specified if
    **    dictionary object file is in create mode. In read mode, the
    **    dictionary object file content is retrieved from the persistent
    **    storage file. In create mode its content will be built from the file
    **    specified by this parameter.
    **
    **  \return Not applicable
    **
    **  \pre None
    **
    **  \post None
    **
    **  \exception FileModeException - if dictionary object file is not in
    **    create mode
    **  \exception InvalidStateException - if dictionary and/or DDL file are
    **    specified for dictionary object file in read mode.
    **  \exception EmptyValueException - if dictionary and/or DDL file are
    **    not specified for dictionary object file in create mode.
    */
    DictObjFile(const string& persStorFileName, const eFileMode fileMode =
      READ_MODE, const bool verbose = false, const string& dictSdbFileName =
      std::string());

    /**
    **  Destructs a dictionary object file, by releasing all consumed
    **  resources.
    **
    **  \param: Not applicable 
    **    
    **  \return Not applicable
    **
    **  \pre None
    **
    **  \post None
    **
    **  \exception: None
    */
    ~DictObjFile();

    /**
    **  Builds a dictionary object file from the dictionary. This method
    **  parses the dictionary, parses the DDL, verifies the dictionary
    **  against the DDL and constructs objects.
    **
    **  \param: None
    **
    **  \return None
    **
    **  \pre None
    **
    **  \post None
    **
    **  \exception FileModeException - if dictionary object file is not in
    **    create mode
    */
    void Build();

    /**
    **  Writes a dictionary object file to the persistent storage file.
    **
    **  \param: None
    **
    **  \return None
    **
    **  \pre None
    **
    **  \post None
    **
    **  \exception FileModeException - if dictionary object file is not in
    **    create mode
    */
    void Write();

    /**
    **  Reads a dictionary object file from the persistent storage file.
    **
    **  \param: None
    **
    **  \return None
    **
    **  \pre None
    **
    **  \post None
    **
    **  \exception FileModeException - if dictionary object file is not in
    **    read mode
    */
    void Read();

    /**
    **  Retrieves the number of dictionaries in the dictionary object file.
    **
    **  \param: None
    **
    **  \return The number of dictionaries in the dictionary object file.
    **
    **  \pre None
    **
    **  \post None
    **
    **  \exception: None
    */
    unsigned int GetNumDictionaries();

    /**
    **  Retrieves dictionary names of the dictionaries in the dictionary
    **  object file.
    **
    **  \param[out] dictNames - retrieved dictionary names
    **
    **  \return None
    **
    **  \pre None
    **
    **  \post None
    **
    **  \exception: None
    */
    void GetDictionaryNames(vector<string>& dictNames);

    /**
    **  Retrieves a reference to the dictionary object.
    **
    **  \param[in] dictName - dictionary name
    **
    **  \return Reference to the dictionary object.
    **
    **  \pre Dictionary with name \e dictName must be present
    **
    **  \post None
    **
    **  \exception NotFoundException - if dictionary with name \e dictName
    **    does not exist
    */
    DictObjCont& GetDictObjCont(const string& dictName);

    /**
    **  Prints the content of the dictionary object file.
    **
    **  \param: None
    **
    **  \return None
    **
    **  \pre None
    **
    **  \post None
    **
    **  \exception: None
    */
    void Print();

  private:
    eFileMode _fileMode;
    bool _verbose;

    string _dictSdbFileName;

    DicFile* _dicFileP;
    Serializer& _ser;

    mapped_ptr_vector<DictObjCont> _dictionaries;

    DictObjCont* _currDictObjContP;
};


#endif // DICTOBJFILE_H