OpenASIP 2.2
Loading...
Searching...
No Matches
OSEdOptionsSerializer.cc
Go to the documentation of this file.
1/*
2 Copyright (c) 2002-2009 Tampere University.
3
4 This file is part of TTA-Based Codesign Environment (TCE).
5
6 Permission is hereby granted, free of charge, to any person obtaining a
7 copy of this software and associated documentation files (the "Software"),
8 to deal in the Software without restriction, including without limitation
9 the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 and/or sell copies of the Software, and to permit persons to whom the
11 Software is furnished to do so, subject to the following conditions:
12
13 The above copyright notice and this permission notice shall be included in
14 all copies or substantial portions of the Software.
15
16 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 DEALINGS IN THE SOFTWARE.
23 */
24/**
25 * @file OSEdOptionsSerializer.cc
26 *
27 * Definition of OSEdOptionsSerializer class.
28 *
29 * @author Jussi Nykänen 2004 (nykanen-no.spam-cs.tut.fi)
30 * @note rating: red
31 */
32
34
35using std::string;
36
37/**
38 * Constructor.
39 */
42
43/**
44 * Destructor.
45 */
48
49/**
50 * Writes the object state tree to XML file.
51 *
52 * @param state State to be written.
53 */
54void
56 try {
58 } catch (const Exception& e) {
59 string method = "OSEdOptionsSerializer::writeState()";
60 string msg = "Problems writing the state: " + e.errorMessage();
61 throw SerializerException(__FILE__, __LINE__, method, msg);
62 }
63}
64
65/**
66 * Reads the options file and returns the corresponding ObjectState tree.
67 *
68 * @return The read ObjectState tree.
69 */
72 ObjectState* root = NULL;
73 try {
74 root = serializer_.readState();
75 } catch (const Exception& e) {
76 string method = "OSEdOptionsSerializer::readState()";
77 string msg = "Problems reading the state: " + e.errorMessage();
78 throw SerializerException(__FILE__, __LINE__, method, msg);
79 }
80 return root;
81}
82
83/**
84 * Sets the source file.
85 *
86 * @param fileName The name of the file.
87 */
88void
89OSEdOptionsSerializer::setSourceFile(const std::string& fileName) {
90 serializer_.setSourceFile(fileName);
91}
92
93/**
94 * Sets the destination file.
95 *
96 * @param fileName The name of the file.
97 */
98void
99OSEdOptionsSerializer::setDestinationFile(const std::string& fileName) {
101}
102
103/**
104 * Sets the schema file.
105 *
106 * @param fileName The name of the file.
107 */
108void
109OSEdOptionsSerializer::setSchemaFile(const std::string& fileName) {
110 serializer_.setSchemaFile(fileName);
111}
112
113/**
114 * Modifies the usage of schema file (yes/no).
115 *
116 * @param useSchema True or false, depending on if schema should be used or not.
117 */
118void
120 serializer_.setUseSchema(useSchema);
121}
std::string errorMessage() const
Definition Exception.cc:123
void setUseSchema(bool useSchema)
virtual ObjectState * readState()
void setSourceFile(const std::string &fileName)
virtual void writeState(const ObjectState *state)
XMLSerializer serializer_
Instance of XMLSerializer.
void setDestinationFile(const std::string &fileName)
void setSchemaFile(const std::string &fileName)
void setUseSchema(bool useSchema)
void setSchemaFile(const std::string &fileName)
void setSourceFile(const std::string &fileName)
virtual void writeState(const ObjectState *rootState)
void setDestinationFile(const std::string &fileName)
virtual ObjectState * readState()