ComparatorLibs: Add stringify to hierarchy for easy printing
This commit is contained in:
@@ -3,6 +3,8 @@
|
||||
|
||||
#include <cstdint>
|
||||
#include <memory>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <mentalEntity.h>
|
||||
#include <user/logic.h>
|
||||
|
||||
@@ -43,6 +45,14 @@ struct ComparatorTypeId
|
||||
{
|
||||
return !(*this == other);
|
||||
}
|
||||
|
||||
std::string stringify() const
|
||||
{
|
||||
std::ostringstream result;
|
||||
result << std::hex << std::showbase;
|
||||
result << "vendorId=" << vendorId << " typeId=" << typeId;
|
||||
return result.str();
|
||||
}
|
||||
};
|
||||
|
||||
class Comparator
|
||||
|
||||
@@ -32,6 +32,11 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string stringify() const
|
||||
{
|
||||
return name + " (" + typeId.stringify() + ")";
|
||||
}
|
||||
|
||||
public:
|
||||
std::string name;
|
||||
ComparatorTypeId typeId;
|
||||
@@ -56,6 +61,20 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string stringify() const
|
||||
{
|
||||
std::string result = "Name: " + name + "\n";
|
||||
result += "Exported Comparator Types:\n";
|
||||
for (size_t i = 0; i < exportedComparatorTypes.size(); ++i)
|
||||
{
|
||||
result += " - " + exportedComparatorTypes[i].stringify();
|
||||
if (i + 1 < exportedComparatorTypes.size()) {
|
||||
result += "\n";
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public:
|
||||
std::string name;
|
||||
std::vector<ExportedComparatorTypeDesc> exportedComparatorTypes;
|
||||
|
||||
@@ -90,8 +90,12 @@ public:
|
||||
{
|
||||
std::string result = "Name: " + name + "\n";
|
||||
result += "Exported QualeIface APIs:\n";
|
||||
for (const auto& api : exportedQualeIfaceApis) {
|
||||
result += " - " + api.name + "\n";
|
||||
for (size_t i = 0; i < exportedQualeIfaceApis.size(); ++i)
|
||||
{
|
||||
result += " - " + exportedQualeIfaceApis[i].name;
|
||||
if (i + 1 < exportedQualeIfaceApis.size()) {
|
||||
result += "\n";
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
+15
-2
@@ -50,8 +50,21 @@ BodyViralPostingInvoker<void> Body::initializeCReq()
|
||||
*/
|
||||
mind.bodyComponentInitialized = true;
|
||||
|
||||
std::cout << stim_buff::StimBuffApiManager::getInstance().stringifyLibs()
|
||||
<< std::endl;
|
||||
const std::string comparatorLibs =
|
||||
comparator_lib::ComparatorApiManager::getInstance().stringifyLibs();
|
||||
const std::string stimBuffLibs =
|
||||
stim_buff::StimBuffApiManager::getInstance().stringifyLibs();
|
||||
|
||||
if (!comparatorLibs.empty()) {
|
||||
std::cout << comparatorLibs;
|
||||
}
|
||||
if (!comparatorLibs.empty() && !stimBuffLibs.empty()) {
|
||||
std::cout << '\n';
|
||||
}
|
||||
if (!stimBuffLibs.empty()) {
|
||||
std::cout << stimBuffLibs;
|
||||
}
|
||||
std::cout << std::endl;
|
||||
|
||||
if (OptionParser::getOptions().verbose)
|
||||
{
|
||||
|
||||
@@ -180,5 +180,18 @@ std::unique_ptr<cologex::Comparator> ComparatorApiManager::getNewComparatorInsta
|
||||
return comparatorType->getNewInstance();
|
||||
}
|
||||
|
||||
std::string ComparatorApiManager::stringifyLibs() const
|
||||
{
|
||||
std::string result;
|
||||
for (const auto& lib : s.rsrc.libs)
|
||||
{
|
||||
if (!result.empty()) {
|
||||
result += "\n";
|
||||
}
|
||||
result += lib->stringify();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
} // namespace comparator_lib
|
||||
} // namespace smo
|
||||
|
||||
@@ -54,6 +54,8 @@ public:
|
||||
const std::shared_ptr<cologex::ExportedComparatorTypeDesc>&
|
||||
comparatorType);
|
||||
|
||||
std::string stringifyLibs() const;
|
||||
|
||||
public:
|
||||
sscl::SharedResourceGroup<sscl::co::CoQutex, Resources> s;
|
||||
|
||||
|
||||
@@ -42,6 +42,15 @@ public:
|
||||
comparatorLibDesc = desc;
|
||||
}
|
||||
|
||||
std::string stringify() const
|
||||
{
|
||||
std::string result = "Library Path: "
|
||||
+ loadedSharedLibrary->libraryPath + "\n";
|
||||
result += "Comparator Library Descriptor: "
|
||||
+ comparatorLibDesc.stringify();
|
||||
return result;
|
||||
}
|
||||
|
||||
public:
|
||||
std::shared_ptr<loadable_lib::LoadableLibraryManager::LoadedSharedLibrary>
|
||||
loadedSharedLibrary;
|
||||
|
||||
@@ -42,6 +42,16 @@ public:
|
||||
{
|
||||
return dlopenHandle.get();
|
||||
}
|
||||
|
||||
std::string stringify() const
|
||||
{
|
||||
std::string result = "Library Path: " + libraryPath + "\n";
|
||||
result += "Resolved Path: " + resolvedPath + "\n";
|
||||
result += "Is Being Destroyed: ";
|
||||
result += (isBeingDestroyed.load() ? "true" : "false");
|
||||
result += "\n";
|
||||
return result;
|
||||
}
|
||||
};
|
||||
|
||||
struct Resources
|
||||
|
||||
@@ -76,7 +76,7 @@ public:
|
||||
{
|
||||
std::string result = "Library Path: "
|
||||
+ loadedSharedLibrary->libraryPath + "\n";
|
||||
result += "Stim Buff API Descriptor: " + stimBuffApiDesc.stringify() + "\n";
|
||||
result += "Stim Buff API Descriptor: " + stimBuffApiDesc.stringify();
|
||||
return result;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -245,8 +245,12 @@ void StimBuffApiManager::loadAllStimBuffApiLibsFromOptions(void)
|
||||
std::string StimBuffApiManager::stringifyLibs() const
|
||||
{
|
||||
std::string result;
|
||||
for (const auto& lib : s.rsrc.libs) {
|
||||
result += lib->stringify() + "\n";
|
||||
for (const auto& lib : s.rsrc.libs)
|
||||
{
|
||||
if (!result.empty()) {
|
||||
result += "\n";
|
||||
}
|
||||
result += lib->stringify();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user