OpenASIP  2.0
OperationBehaviorProxy.hh
Go to the documentation of this file.
1 /*
2  Copyright (c) 2002-2011 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 OperationBehaviorProxy.hh
26  *
27  * Declaration of OperationBehaviorProxy class.
28  *
29  * @author Jussi Nykänen 2004 (nykanen-no.spam-cs.tut.fi)
30  * @author Pekka Jääskeläinen 2005,2011 (pjaaskel-no.spam-cs.tut.fi)
31  *
32  * @note rating: yellow
33  * @note reviewed 19 August 2004 by pj, jn, ao, ac
34  */
35 
36 #ifndef TTA_OPERATION_BEHAVIOR_PROXY_HH
37 #define TTA_OPERATION_BEHAVIOR_PROXY_HH
38 
39 #include <vector>
40 #include <set>
41 
42 #include "OperationBehavior.hh"
43 #include "OperationDAGBehavior.hh"
44 
45 class Operation;
46 class SimValue;
47 class OperationContext;
49 
50 /**
51  * This class is used to create a behavior model of an operation.
52  *
53  * A first time operation calls simulateTrigger()
54  * proxy creates the appropriate operation behavior model for the operation.
55  * Proxy replaces itself in the operation with the newly created behavior
56  * model. That new model then executes all simulation functions.
57  */
59 public:
61  Operation& targetOperation,
63  bool alwaysReloadBehavior=false);
64 
65  virtual ~OperationBehaviorProxy();
66 
67  virtual bool simulateTrigger(
68  SimValue** io,
69  OperationContext& context) const;
70 
71  virtual bool canBeSimulated() const;
72 
73  virtual void createState(OperationContext& context) const;
74  virtual void deleteState(OperationContext& context) const;
75 
76  virtual void setAlwaysReloadBehavior(bool f) { alwaysReloadBehavior_ = f; }
77  void uninitializeBehavior() const;
78 
79 private:
80  /// Copying not allowed.
82  /// Assignment not allowed.
84 
85  void initializeBehavior() const;
86 
87  /// Operation that owns this proxy;
89  /// Used to load behavior model for operation.
91  /// Flag indicating whether proxy is initialized or not.
92  mutable bool initialized_;
93  /// Clean up list for created OperationDAGBehaviors
94  mutable std::set<OperationDAGBehavior*> cleanUs_;
95  /// If this is true, the behavior is always (re)loaded from the
96  /// dynamic library or the DAG instead of loading it once and
97  /// reusing in the future calls.
99  /// Helpers variable to catch infinite recursive function call due to
100  /// missing or undefined operation behavior.
101  mutable bool alreadyCreatingState_;
102 };
103 
104 #endif
OperationBehaviorProxy::alwaysReloadBehavior_
bool alwaysReloadBehavior_
If this is true, the behavior is always (re)loaded from the dynamic library or the DAG instead of loa...
Definition: OperationBehaviorProxy.hh:98
OperationDAGBehavior.hh
OperationBehaviorProxy::setAlwaysReloadBehavior
virtual void setAlwaysReloadBehavior(bool f)
Definition: OperationBehaviorProxy.hh:76
OperationContext
Definition: OperationContext.hh:56
OperationBehaviorProxy::~OperationBehaviorProxy
virtual ~OperationBehaviorProxy()
Definition: OperationBehaviorProxy.cc:70
OperationBehaviorProxy::target_
Operation * target_
Operation that owns this proxy;.
Definition: OperationBehaviorProxy.hh:88
OperationBehaviorProxy::canBeSimulated
virtual bool canBeSimulated() const
Definition: OperationBehaviorProxy.cc:162
SimValue
Definition: SimValue.hh:96
OperationBehaviorProxy::initialized_
bool initialized_
Flag indicating whether proxy is initialized or not.
Definition: OperationBehaviorProxy.hh:92
OperationBehaviorProxy
Definition: OperationBehaviorProxy.hh:58
OperationBehaviorProxy::initializeBehavior
void initializeBehavior() const
Definition: OperationBehaviorProxy.cc:195
OperationBehaviorLoader
Definition: OperationBehaviorLoader.hh:54
Operation
Definition: Operation.hh:59
OperationBehaviorProxy::uninitializeBehavior
void uninitializeBehavior() const
Definition: OperationBehaviorProxy.cc:244
OperationBehavior.hh
OperationBehavior
Definition: OperationBehavior.hh:53
OperationBehaviorProxy::deleteState
virtual void deleteState(OperationContext &context) const
Definition: OperationBehaviorProxy.cc:145
OperationBehaviorProxy::simulateTrigger
virtual bool simulateTrigger(SimValue **io, OperationContext &context) const
Definition: OperationBehaviorProxy.cc:91
OperationBehaviorProxy::alreadyCreatingState_
bool alreadyCreatingState_
Helpers variable to catch infinite recursive function call due to missing or undefined operation beha...
Definition: OperationBehaviorProxy.hh:101
OperationBehaviorProxy::cleanUs_
std::set< OperationDAGBehavior * > cleanUs_
Clean up list for created OperationDAGBehaviors.
Definition: OperationBehaviorProxy.hh:94
OperationBehaviorProxy::createState
virtual void createState(OperationContext &context) const
Definition: OperationBehaviorProxy.cc:111
OperationBehaviorProxy::loader_
OperationBehaviorLoader * loader_
Used to load behavior model for operation.
Definition: OperationBehaviorProxy.hh:90
OperationBehaviorProxy::OperationBehaviorProxy
OperationBehaviorProxy(Operation &targetOperation, OperationBehaviorLoader &loader, bool alwaysReloadBehavior=false)
Definition: OperationBehaviorProxy.cc:56
OperationBehaviorProxy::operator=
OperationBehaviorProxy & operator=(const OperationBehaviorProxy &)
Assignment not allowed.