manager.cpp (66e0707365379e8716703e9175f82faa1f5b37ad) manager.cpp (54ea3ad8db163d57261344167571eadfd8db94e1)
1/**
2 * Copyright © 2018 IBM Corporation
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0

--- 95 unchanged lines hidden (view full) ---

104void Manager::erase(EntryID id)
105{
106 fs::remove_all(getSaveDir(id));
107 childEntries.erase(id);
108 entries.erase(id);
109}
110
111void Manager::addInterface(const std::string& objectPath, InterfaceType type,
1/**
2 * Copyright © 2018 IBM Corporation
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0

--- 95 unchanged lines hidden (view full) ---

104void Manager::erase(EntryID id)
105{
106 fs::remove_all(getSaveDir(id));
107 childEntries.erase(id);
108 entries.erase(id);
109}
110
111void Manager::addInterface(const std::string& objectPath, InterfaceType type,
112 std::experimental::any& object)
112 std::any& object)
113{
114 auto id = getEntryID(objectPath);
115 auto entry = entries.find(id);
116
117 if (entry == entries.end())
118 {
119 InterfaceMap interfaces;
120 interfaces.emplace(type, object);
121 entries.emplace(id, std::move(interfaces));
122 }
123 else
124 {
125 entry->second.emplace(type, object);
126 }
127}
128
129void Manager::addChildInterface(const std::string& objectPath,
113{
114 auto id = getEntryID(objectPath);
115 auto entry = entries.find(id);
116
117 if (entry == entries.end())
118 {
119 InterfaceMap interfaces;
120 interfaces.emplace(type, object);
121 entries.emplace(id, std::move(interfaces));
122 }
123 else
124 {
125 entry->second.emplace(type, object);
126 }
127}
128
129void Manager::addChildInterface(const std::string& objectPath,
130 InterfaceType type,
131 std::experimental::any& object)
130 InterfaceType type, std::any& object)
132{
133 auto id = getEntryID(objectPath);
134 auto entry = childEntries.find(id);
135
136 // childEntries is:
137 // A map of error log entry IDs to:
138 // a map of interface types to:
139 // a vector of interface objects

--- 28 unchanged lines hidden (view full) ---

168
169 auto object = std::make_shared<PolicyObject>(bus, objectPath.c_str(), true);
170
171 object->eventID(std::get<policy::EIDField>(values));
172 object->description(std::get<policy::MsgField>(values));
173
174 object->emit_object_added();
175
131{
132 auto id = getEntryID(objectPath);
133 auto entry = childEntries.find(id);
134
135 // childEntries is:
136 // A map of error log entry IDs to:
137 // a map of interface types to:
138 // a vector of interface objects

--- 28 unchanged lines hidden (view full) ---

167
168 auto object = std::make_shared<PolicyObject>(bus, objectPath.c_str(), true);
169
170 object->eventID(std::get<policy::EIDField>(values));
171 object->description(std::get<policy::MsgField>(values));
172
173 object->emit_object_added();
174
176 std::experimental::any anyObject = object;
175 std::any anyObject = object;
177
178 addInterface(objectPath, InterfaceType::POLICY, anyObject);
179}
180#endif
181
182void Manager::createCalloutObjects(const std::string& objectPath,
183 const DbusInterfaceMap& interfaces)
184{

--- 57 unchanged lines hidden (view full) ---

242
243 auto dir = getCalloutSaveDir(id);
244 if (!fs::exists(dir))
245 {
246 fs::create_directories(dir);
247 }
248 object->serialize(dir);
249
176
177 addInterface(objectPath, InterfaceType::POLICY, anyObject);
178}
179#endif
180
181void Manager::createCalloutObjects(const std::string& objectPath,
182 const DbusInterfaceMap& interfaces)
183{

--- 57 unchanged lines hidden (view full) ---

241
242 auto dir = getCalloutSaveDir(id);
243 if (!fs::exists(dir))
244 {
245 fs::create_directories(dir);
246 }
247 object->serialize(dir);
248
250 std::experimental::any anyObject = object;
249 std::any anyObject = object;
251 addChildInterface(objectPath, InterfaceType::CALLOUT, anyObject);
252 calloutNum++;
253 }
254 catch (const SdBusError& e)
255 {
256 log<level::ERR>("sdbusplus exception", entry("ERROR=%s", e.what()));
257 }
258 }

--- 25 unchanged lines hidden (view full) ---

284 }
285
286 auto path = getCalloutObjectPath(objectPath, id);
287 auto callout = std::make_shared<Callout>(bus, path, id,
288 getLogTimestamp(interfaces));
289 if (callout->deserialize(saveDir))
290 {
291 callout->emit_object_added();
250 addChildInterface(objectPath, InterfaceType::CALLOUT, anyObject);
251 calloutNum++;
252 }
253 catch (const SdBusError& e)
254 {
255 log<level::ERR>("sdbusplus exception", entry("ERROR=%s", e.what()));
256 }
257 }

--- 25 unchanged lines hidden (view full) ---

283 }
284
285 auto path = getCalloutObjectPath(objectPath, id);
286 auto callout = std::make_shared<Callout>(bus, path, id,
287 getLogTimestamp(interfaces));
288 if (callout->deserialize(saveDir))
289 {
290 callout->emit_object_added();
292 std::experimental::any anyObject = callout;
291 std::any anyObject = callout;
293 addChildInterface(objectPath, InterfaceType::CALLOUT, anyObject);
294 }
295 }
296}
297
298void Manager::interfaceAdded(sdbusplus::message::message& msg)
299{
300 sdbusplus::message::object_path path;

--- 62 unchanged lines hidden ---
292 addChildInterface(objectPath, InterfaceType::CALLOUT, anyObject);
293 }
294 }
295}
296
297void Manager::interfaceAdded(sdbusplus::message::message& msg)
298{
299 sdbusplus::message::object_path path;

--- 62 unchanged lines hidden ---