OpenASIP  2.0
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 
33 #include "OSEdOptionsSerializer.hh"
34 
35 using std::string;
36 
37 /**
38  * Constructor.
39  */
41 }
42 
43 /**
44  * Destructor.
45  */
47 }
48 
49 /**
50  * Writes the object state tree to XML file.
51  *
52  * @param state State to be written.
53  */
54 void
56  try {
57  serializer_.writeState(state);
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  */
88 void
89 OSEdOptionsSerializer::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  */
98 void
99 OSEdOptionsSerializer::setDestinationFile(const std::string& fileName) {
101 }
102 
103 /**
104  * Sets the schema file.
105  *
106  * @param fileName The name of the file.
107  */
108 void
109 OSEdOptionsSerializer::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  */
118 void
120  serializer_.setUseSchema(useSchema);
121 }
XMLSerializer::setSourceFile
void setSourceFile(const std::string &fileName)
Definition: XMLSerializer.cc:115
OSEdOptionsSerializer::writeState
virtual void writeState(const ObjectState *state)
Definition: OSEdOptionsSerializer.cc:55
OSEdOptionsSerializer::serializer_
XMLSerializer serializer_
Instance of XMLSerializer.
Definition: OSEdOptionsSerializer.hh:64
OSEdOptionsSerializer::OSEdOptionsSerializer
OSEdOptionsSerializer()
Definition: OSEdOptionsSerializer.cc:40
ObjectState
Definition: ObjectState.hh:59
OSEdOptionsSerializer::readState
virtual ObjectState * readState()
Definition: OSEdOptionsSerializer.cc:71
XMLSerializer::setSchemaFile
void setSchemaFile(const std::string &fileName)
Definition: XMLSerializer.cc:168
OSEdOptionsSerializer::setSchemaFile
void setSchemaFile(const std::string &fileName)
Definition: OSEdOptionsSerializer.cc:109
XMLSerializer::readState
virtual ObjectState * readState()
Definition: XMLSerializer.cc:200
XMLSerializer::setDestinationFile
void setDestinationFile(const std::string &fileName)
Definition: XMLSerializer.cc:142
TCETools::Serializer
Definition: Serializer.hh:45
OSEdOptionsSerializer::setDestinationFile
void setDestinationFile(const std::string &fileName)
Definition: OSEdOptionsSerializer.cc:99
OSEdOptionsSerializer::setUseSchema
void setUseSchema(bool useSchema)
Definition: OSEdOptionsSerializer.cc:119
SerializerException
Definition: Exception.hh:675
Exception
Definition: Exception.hh:54
XMLSerializer::setUseSchema
void setUseSchema(bool useSchema)
Definition: XMLSerializer.cc:179
Exception::errorMessage
std::string errorMessage() const
Definition: Exception.cc:123
OSEdOptionsSerializer::~OSEdOptionsSerializer
virtual ~OSEdOptionsSerializer()
Definition: OSEdOptionsSerializer.cc:46
OSEdOptionsSerializer::setSourceFile
void setSourceFile(const std::string &fileName)
Definition: OSEdOptionsSerializer.cc:89
OSEdOptionsSerializer.hh
XMLSerializer::writeState
virtual void writeState(const ObjectState *rootState)
Definition: XMLSerializer.cc:219