OpenASIP  2.0
EditPartFactory.cc
Go to the documentation of this file.
1 /*
2  Copyright (c) 2002-2010 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 EditPartFactory.cc
26  *
27  * Definition of EditPartFactory class.
28  *
29  * @author Ari Metsähalme 2003 (ari.metsahalme-no.spam-tut.fi)
30  * @author Pekka Jääskeläinen 2010
31  * @note rating: yellow
32  * @note reviewed Jul 13 2004 by vpj, ll, jn, am
33  */
34 
35 #include <vector>
36 
37 #include "EditPart.hh"
38 #include "EditPartFactory.hh"
39 #include "SequenceTools.hh"
40 
41 using std::vector;
42 using namespace TTAMachine;
43 
44 vector<EditPart*> EditPartFactory::created_;
45 
46 /**
47  * The Constructor.
48  */
50  Factory(),
51  editPolicyFactory_(editPolicyFactory) {
52 }
53 
54 /**
55  * The Destructor.
56  */
58  // erase data of already created EditParts
59  created_.clear();
61 }
62 
63 /**
64  * Checks if an EditPart of the given component has already been created
65  * and returns it.
66  *
67  * @param component A machine component to check.
68  * @return An EditPart of the given machine component if such has already
69  * been created, NULL otherwise.
70  */
71 EditPart*
72 EditPartFactory::checkCache(const MachinePart* component) const {
73  // check if an EditPart has already been created of the component
74  vector<EditPart*>::const_iterator i = created_.begin();
75  for (; i != created_.end(); i++) {
76  if ((*i)->model() == component) {
77  return *i;
78  }
79  }
80  return NULL;
81 }
82 
83 /**
84  * Inserts an EditPart to the EditPart cache.
85  *
86  * @param editPart The EditPart to insert.
87  */
88 void
90  created_.push_back(editPart);
91 }
EditPolicyFactory
Definition: EditPolicyFactory.hh:46
SequenceTools.hh
EditPartFactory::checkCache
EditPart * checkCache(const TTAMachine::MachinePart *component) const
Definition: EditPartFactory.cc:72
EditPartFactory::~EditPartFactory
virtual ~EditPartFactory()
Definition: EditPartFactory.cc:57
EditPartFactory::writeToCache
void writeToCache(EditPart *editPart)
Definition: EditPartFactory.cc:89
SequenceTools::deleteAllItems
static void deleteAllItems(SequenceType &aSequence)
EditPart.hh
EditPartFactory.hh
TTAMachine::MachinePart
Definition: MachinePart.hh:57
EditPartFactory::EditPartFactory
EditPartFactory(EditPolicyFactory &editPolicyFactory)
Definition: EditPartFactory.cc:49
EditPart
Definition: EditPart.hh:60
Factory
Definition: Factory.hh:46
EditPartFactory::created_
static std::vector< EditPart * > created_
Container for already created EditParts.
Definition: EditPartFactory.hh:62
TTAMachine
Definition: Assembler.hh:48
EditPartFactory::factories_
std::vector< Factory * > factories_
Registered factories.
Definition: EditPartFactory.hh:60