OpenASIP 2.2
Loading...
Searching...
No Matches
InterPassData.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 InterPassData.cc
26 *
27 * Definition of InterPassData class.
28 *
29 * @author Pekka Jääskeläinen 2007 (pjaaskel-no.spam-cs.tut.fi)
30 * @note rating: red
31 */
32
33#include "InterPassData.hh"
34#include "InterPassDatum.hh"
35#include "MapTools.hh"
36
37/**
38 * Constructor.
39 */
42
43/**
44 * Destructor.
45 *
46 * Deletes all added InterPassDatum objects.
47 */
51
52/**
53 * Returns a reference to the datum associated with the given key.
54 *
55 * It is allowed to modify the returned object directly.
56 *
57 * @param key The key.
58 * @returns The datum.
59 * @exception KeyNotFound thrown if the key is not found.
60 */
62InterPassData::datum(const std::string& key) {
64 throw KeyNotFound(__FILE__, __LINE__, __func__);
65
66 return *data_[key];
67}
68
69/**
70 * Returns true if there is a datum for the given key.
71 *
72 * @return True if there is a datum for the given key.
73 */
74bool
75InterPassData::hasDatum(const std::string& key) const {
76 return MapTools::containsKey(data_, key);
77}
78
79/**
80 * Sets a datum for the given key.
81 *
82 * Ownership of the datum is transferred. Possible previously existing
83 * datum at the given key is deleted.
84 *
85 * @param key The key of the datum.
86 * @param datum The datum object.
87 */
88void
89InterPassData::setDatum(const std::string& key, InterPassDatum* datum) {
90
92 delete data_[key];
93 data_[key] = datum;
94}
95
96void
97InterPassData::removeDatum(const std::string& key) {
98 if (MapTools::containsKey(data_, key)) {
99 delete data_[key];
100 data_.erase(key);
101 }
102}
#define __func__
bool hasDatum(const std::string &key) const
virtual ~InterPassData()
std::map< std::string, InterPassDatum * > data_
container for the data
void setDatum(const std::string &key, InterPassDatum *datum)
void removeDatum(const std::string &key)
InterPassDatum & datum(const std::string &key)
static void deleteAllValues(MapType &aMap)
static bool containsKey(const MapType &aMap, const KeyType &aKey)