OpenASIP 2.2
Loading...
Searching...
No Matches
ToolbarButton.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 ToolbarButton.cc
26 *
27 * Implementation of ToolbarButton class.
28 *
29 * @author Lasse Laasonen 2003 (lasse.laasonen-no.spam-tut.fi)
30 * @note rating: red
31 */
32
33#include "ToolbarButton.hh"
34#include "ObjectState.hh"
35
36using std::string;
37
38// initialization of static data members
39const string ToolbarButton::OSNAME_TOOLBAR_BUTTON = "tbbutton";
40const string ToolbarButton::OSKEY_SLOT = "slot";
41const string ToolbarButton::OSKEY_ACTION = "action";
42
43
44/**
45 * Constructor.
46 *
47 * @param slot Number of the slot in which the button is placed.
48 * @param action Name of the action performed by the button.
49 */
51 int slot,
52 const std::string& action) :
53 slot_(slot), action_(action) {
54}
55
56
57/**
58 * Constructor.
59 *
60 * Loads the state from the given ObjectsState object.
61 */
63 loadState(state);
64}
65
66
67/**
68 * Copy constructor.
69 */
75
76
77/**
78 * Destructor.
79 */
82
83
84/**
85 * Returns the name of the action performed by the button.
86 *
87 * @return Name of the action performed by the button.
88 */
89std::string
91 return action_;
92}
93
94
95/**
96 * Returns the position of the slot which contains the button.
97 *
98 * @return Position of the slot which contains the button.
99 */
100int
102 return slot_;
103}
104
105
106/**
107 * Loads the state of the object from the given ObjectState object.
108 *
109 * @param state ObjectState from which the state is loaded.
110 * @exception ObjectStateLoadingException If the given ObjectState instance
111 * is invalid.
112 */
113void
115 string procName = "ToolbarButton::loadState";
116
117 if (state->name() != OSNAME_TOOLBAR_BUTTON) {
118 throw ObjectStateLoadingException(__FILE__, __LINE__, procName);
119 }
120
121 try {
122 slot_ = state->intAttribute(OSKEY_SLOT);
124 } catch (...) {
125 throw ObjectStateLoadingException(__FILE__, __LINE__, procName);
126 }
127}
128
129/**
130 * Creates an ObjectState object and saves the state of the object into it.
131 *
132 * @return The created ObjectState object.
133 */
139 return state;
140}
void setAttribute(const std::string &name, const std::string &value)
std::string stringAttribute(const std::string &name) const
int intAttribute(const std::string &name) const
std::string name() const
void loadState(const ObjectState *state)
ToolbarButton(int slot, const std::string &action)
std::string action_
Name of the action performed by this toolbar button.
static const std::string OSKEY_SLOT
ObjectState attribute key for slot position.
static const std::string OSKEY_ACTION
ObjectState attribute key for action name.
static const std::string OSNAME_TOOLBAR_BUTTON
ObjectState name for ToolbarButton.
int slot() const
std::string action() const
int slot_
Number of the slot in which this toolbar button is.
ObjectState * saveState() const
virtual ~ToolbarButton()