ETISS 0.11.2
ExtendableTranslatingInstructionSetSimulator(version0.11.2)
Loading...
Searching...
No Matches
InjectorAddress.cpp
Go to the documentation of this file.
1// SPDX-License-Identifier: BSD-3-Clause
2//
3// This file is part of ETISS. It is licensed under the BSD 3-Clause License; you may not use this file except in
4// compliance with the License. You should have received a copy of the license along with this project. If not, see the
5// LICENSE file.
6
7#ifndef NO_ETISS
8#include "etiss/fault/XML.h"
11#include "etiss/fault/Trigger.h"
12#include "etiss/fault/Action.h"
13#else
14#include "fault/XML.h"
16#include "fault/Injector.h"
17#include "fault/Trigger.h"
18#include "fault/Action.h"
19#endif
20
21namespace etiss
22{
23namespace fault
24{
25
27{
28 etiss::log(etiss::VERBOSE, "Called etiss::fault::InjectorAddress::InjectorAddress()");
29 path_ = ":";
30 iptr_ = 0;
31}
32InjectorAddress::InjectorAddress(const std::string &address)
33{
34 etiss::log(etiss::VERBOSE, "Called etiss::fault::InjectorAddress::InjectorAddress(address=" + address + ")");
35 path_ = address;
36 iptr_ = 0;
37}
39{
41 "Called etiss::fault::InjectorAddress::InjectorAddress(InjectorAddress=" + cpy.toString() + ")");
42 *this = cpy;
43}
45{
47 "Called etiss::fault::InjectorAddress::operator=(InjectorAddress=" + cpy.toString() + ")");
48 path_ = cpy.path_;
49 iptr_ = cpy.iptr_;
50 return *this;
51}
52
53#if CXX0X_UP_SUPPORTED
54
56{
57 etiss::log(etiss::VERBOSE, "Called etiss::fault::InjectorAddress::InjectorAddress(InjectorAddress && ia)");
58 operator=(ia);
59}
60InjectorAddress &InjectorAddress::operator=(InjectorAddress &&ia)
61{
62 etiss::log(etiss::VERBOSE, "Called etiss::fault::InjectorAddress::operator=(InjectorAddress && ia)");
63 operator=((const InjectorAddress &)ia);
64 return *this;
65}
66
67#endif
68
69const std::string &InjectorAddress::getInjectorPath() const
70{
71 return path_;
72}
74{
75
76 if (!iptr_)
77 {
79 if (!iptr_)
80 {
81#ifdef NO_ETISS
82 std::cout << "etiss::fault::InjectorAddress::getInjector(): Injector not found for path_=" << path_
83 << std::endl;
84#else
85 etiss::log(etiss::ERROR, std::string("etiss::fault::InjectorAddress::getInjector():") +
86 std::string(" Injector not found for path_= ") + path_);
87#endif
88 }
89 }
90 return iptr_;
91}
92
94{
95 return (bool)iptr_;
96}
97
98#if ETISS_FAULT_XML
99namespace xml
100{
101
102template <>
103bool parse<etiss::fault::InjectorAddress>(pugi::xml_node node, etiss::fault::InjectorAddress &dst, Diagnostics &diag)
104{
105 etiss::log(etiss::VERBOSE, std::string("Called etiss::fault::xml::parse<etiss::fault::") +
106 "InjectorAddress>(node, InjectorAddress&=" + dst.toString() + ", Diagnostics&)");
107 std::string val;
108 if (!parse<std::string>(node, val, diag))
109 {
110 return false;
111 }
112 setCoreName(val);
113 dst = InjectorAddress(val);
114 return true;
115}
116template <>
117bool write<etiss::fault::InjectorAddress>(pugi::xml_node node, const etiss::fault::InjectorAddress &src,
118 Diagnostics &diag)
119{
120 etiss::log(etiss::VERBOSE, std::string("Called etiss::fault::xml::write<etiss::fault::") +
121 "InjectorAddress>(node, InjectorAddress&=" + src.toString() + ", Diagnostics&)");
122 return write<std::string>(node, src.getInjectorPath(), diag);
123}
124
125template <>
126bool parse<etiss::fault::InjectorAddress *>(pugi::xml_node node, etiss::fault::InjectorAddress *&dst, Diagnostics &diag)
127{
128 etiss::log(etiss::VERBOSE, std::string("Called etiss::fault::xml::parse<etiss::fault::") +
129 "InjectorAddress*>(node, InjectorAddress*&=" + dst->toString() + ", Diagnostics&)");
130 InjectorAddress val;
131 if (!parse<etiss::fault::InjectorAddress>(node, val, diag))
132 {
133 dst = 0;
134 return false;
135 }
136 dst = new InjectorAddress(val);
137 return true;
138}
139template <>
140bool write<const etiss::fault::InjectorAddress *>(pugi::xml_node node, const etiss::fault::InjectorAddress *const &src,
141 Diagnostics &diag)
142{
143 etiss::log(etiss::VERBOSE, std::string("Called etiss::fault::xml::write<etiss::fault::") +
144 "InjectorAddress*>(node, InjectorAddress*&=" + src->toString() + ", Diagnostics&)");
145 if (!src)
146 return false;
147 return write(node, *src, diag);
148}
149
150} // namespace xml
151#endif
152
153} // namespace fault
154
155} // namespace etiss
contains an action class that describes actions associated with a fault
contains a simple class that represents and resolves injector addresses as used by triggers (
contains the fault injector interface class.
contains the Trigger class that defines conditions under which actions of a Fault need to be applied.
contains XML related functions.
InjectorAddress & operator=(const InjectorAddress &)
const std::string & getInjectorPath() const
bool isResolved() const
> Calls Injector::get (implemented in VirtualStruct) to resolve path_ and get iptr_
const Injector_ptr & getInjector() const
Injector_ptr iptr_
Contains the pointer to the Injector.
std::string path_
Contains the VirtualStruct as string where the Injector refers to.
static ptr get(const std::string &injectorPath)
void setCoreName(std::string &str)
Definition XML.cpp:26
std::shared_ptr< Injector > Injector_ptr
Definition Defs.h:48
forwards: include/jit/*
Definition Benchmark.h:17
@ VERBOSE
Definition Misc.h:88
@ ERROR
Definition Misc.h:85
void log(Verbosity level, std::string msg)
write log message at the given level.
Definition Misc.cpp:94