OpenASIP 2.2
Loading...
Searching...
No Matches
ProDeOptionsSerializer.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 ProDeOptionsSerializer.cc
26 *
27 * Implementation of ProDeOptionsSerializer class.
28 *
29 * @author Veli-Pekka Jääskeläinen 2005 (vjaaskel-no.spam-cs.tut.fi)
30 * @note rating: red
31 */
32
34#include "Application.hh"
35#include "Conversion.hh"
36#include "ObjectState.hh"
37#include "ProDeOptions.hh"
38
39using std::string;
40
41/// Name of the element declaring the size of the undo stack.
42const string UNDO = "undo-stack";
43/// Name of the attribute of the undo element.
44const string UNDO_SIZE = "size";
45
46/// Default undo stack size.
47const int DEFAULT_UNDO_SIZE = 10;
48
49
50/**
51 * Constructor.
52 */
56
57
58/**
59 * Destructor.
60 */
63
64
65/**
66 * Converts the given ObjectState tree created by ProDeOptions::saveState
67 * to the format of configuration file.
68 *
69 * @param options ObjectState tree to be converted.
70 * @return The newly created ObjectState tree which matches with
71 * configuration file format.
72 */
75 const ObjectState* options) const {
76
77 ObjectState* root =
79
80 // add undo stack size
81 ObjectState* undoStack = new ObjectState(UNDO);
82 root->addChild(undoStack);
83 undoStack->setAttribute(
84 UNDO_SIZE, options->stringAttribute(
86
87 return root;
88}
89
90
91/**
92 * Creates a new ObjectState tree which can be given to ProDeOptions
93 * constructor. The tree is created according to the given tree which matches
94 * with the syntax of the options file.
95 *
96 * @param root Root node of the ObjectState tree to be converted.
97 */
100 const ObjectState* root) const {
101
104
105 // set undo stack size
106 if (root->hasChild(UNDO)) {
107 ObjectState* undo = root->childByName(UNDO);
108 options->setAttribute(
111 } else {
112 options->setAttribute(
114 }
115
116 return options;
117}
static MachInfoCmdLineOptions options
Definition MachInfo.cc:46
const int DEFAULT_UNDO_SIZE
Default undo stack size.
const string UNDO
Name of the element declaring the size of the undo stack.
const string UNDO_SIZE
Name of the attribute of the undo element.
virtual ObjectState * convertToOptionsObjectFormat(const ObjectState *root) const
virtual ObjectState * convertToConfigFileFormat(const ObjectState *options) const
ObjectState * childByName(const std::string &name) const
void setAttribute(const std::string &name, const std::string &value)
bool hasChild(const std::string &name) const
void addChild(ObjectState *child)
std::string stringAttribute(const std::string &name) const
ObjectState * convertToConfigFileFormat(const ObjectState *options) const
ObjectState * convertToOptionsObjectFormat(const ObjectState *root) const
static const std::string OSKEY_UNDO_STACK_SIZE
ObjectState attribute key for the size of the undo stack.