OpenASIP  2.0
OSEdOptions.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 OSEdOptions.cc
26  *
27  * Definition of OSEdOptions class.
28  *
29  * @author Jussi Nykänen 2004 (nykanen-no.spam-cs.tut.fi)
30  * @note rating: red
31  */
32 
33 #include "OSEdOptions.hh"
34 #include "ObjectState.hh"
35 
36 using std::string;
37 
38 const string OSED_CONF = "osed-configuration";
39 const string OSED_EDITOR = "editor";
40 
41 /**
42  * Constructor.
43  */
44 OSEdOptions::OSEdOptions() : editor_("") {
45 }
46 
47 /**
48  * Destructor.
49  */
51 }
52 
53 /**
54  * Returns the editor.
55  *
56  * @return The editor.
57  */
58 string
60  return editor_;
61 }
62 
63 /**
64  * Sets the editor.
65  *
66  * @param editor. Editor to be set.
67  */
68 void
69 OSEdOptions::setEditor(const std::string& editor) {
70  editor_ = editor;
71 }
72 
73 /**
74  * Loads the state from the object tree.
75  *
76  * @param state The to be loaded.
77  */
78 void
80  try {
81  for (int i = 0; i < state->childCount(); i++) {
82  ObjectState* child = state->child(i);
83  if (child->name() == OSED_EDITOR) {
84  editor_ = child->stringValue();
85  }
86  }
87  } catch (const Exception& e) {
88  string method = "OSEdOptions::loadState()";
89  string msg = "Problems loading state: " + e.errorMessage();
90  throw ObjectStateLoadingException(__FILE__, __LINE__, method, msg);
91  }
92 }
93 
94 /**
95  * Saves the state of the options in ObjectState tree.
96  *
97  * @return The created ObjectState tree.
98  */
101  ObjectState* root = new ObjectState(OSED_CONF);
103  editor->setValue(editor_);
104  root->addChild(editor);
105  return root;
106 }
OSEdOptions::setEditor
void setEditor(const std::string &editor)
Definition: OSEdOptions.cc:69
OSEdOptions::editor_
std::string editor_
Editor used to edit operation behavior files.
Definition: OSEdOptions.hh:63
ObjectStateLoadingException
Definition: Exception.hh:551
OSEdOptions::saveState
ObjectState * saveState() const
Definition: OSEdOptions.cc:100
ObjectState
Definition: ObjectState.hh:59
OSEdOptions::~OSEdOptions
virtual ~OSEdOptions()
Definition: OSEdOptions.cc:50
OSED_CONF
const string OSED_CONF
Definition: OSEdOptions.cc:38
ObjectState.hh
ObjectState::child
ObjectState * child(int index) const
Definition: ObjectState.cc:471
ObjectState::addChild
void addChild(ObjectState *child)
Definition: ObjectState.cc:376
ObjectState::childCount
int childCount() const
Exception
Definition: Exception.hh:54
ObjectState::name
std::string name() const
Exception::errorMessage
std::string errorMessage() const
Definition: Exception.cc:123
OSED_EDITOR
const string OSED_EDITOR
Definition: OSEdOptions.cc:39
OSEdOptions::loadState
virtual void loadState(const ObjectState *state)
Definition: OSEdOptions.cc:79
OSEdOptions::OSEdOptions
OSEdOptions()
Definition: OSEdOptions.cc:44
ObjectState::stringValue
std::string stringValue() const
OSEdOptions.hh
OSEdOptions::editor
std::string editor() const
Definition: OSEdOptions.cc:59