mirror of
https://github.com/Icinga/icinga2.git
synced 2025-09-24 10:17:59 +02:00
Introduce ObjectImpl<ConfigObject>#GetParentsAffectingLogging()
This commit is contained in:
parent
071dae815e
commit
fd4d3e88b9
@ -135,6 +135,7 @@ deprecated { yylval->num = FADeprecated; return T_FIELD_ATTRIBUTE; }
|
|||||||
get_virtual { yylval->num = FAGetVirtual; return T_FIELD_ATTRIBUTE; }
|
get_virtual { yylval->num = FAGetVirtual; return T_FIELD_ATTRIBUTE; }
|
||||||
set_virtual { yylval->num = FASetVirtual; return T_FIELD_ATTRIBUTE; }
|
set_virtual { yylval->num = FASetVirtual; return T_FIELD_ATTRIBUTE; }
|
||||||
signal_with_old_value { yylval->num = FASignalWithOldValue; return T_FIELD_ATTRIBUTE; }
|
signal_with_old_value { yylval->num = FASignalWithOldValue; return T_FIELD_ATTRIBUTE; }
|
||||||
|
parent_affecting_logging { yylval->num = FAParentAffectingLogging; return T_FIELD_ATTRIBUTE; }
|
||||||
virtual { yylval->num = FAGetVirtual | FASetVirtual; return T_FIELD_ATTRIBUTE; }
|
virtual { yylval->num = FAGetVirtual | FASetVirtual; return T_FIELD_ATTRIBUTE; }
|
||||||
navigation { return T_NAVIGATION; }
|
navigation { return T_NAVIGATION; }
|
||||||
validator { return T_VALIDATOR; }
|
validator { return T_VALIDATOR; }
|
||||||
|
@ -1087,6 +1087,87 @@ void ClassCompiler::HandleClass(const Klass& klass, const ClassDebugInfo&)
|
|||||||
<< field.GetFriendlyName() << "ChangedWithOldValue;" << std::endl << std::endl;
|
<< field.GetFriendlyName() << "ChangedWithOldValue;" << std::endl << std::endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* override ConfigObject#GetParentsAffectingLogging() */
|
||||||
|
|
||||||
|
bool overrideGetParentsAffectingLogging = klass.Name == "ConfigObject";
|
||||||
|
|
||||||
|
if (!overrideGetParentsAffectingLogging) {
|
||||||
|
for (auto& field : klass.Fields) {
|
||||||
|
if (field.Attributes & FAParentAffectingLogging && (field.Type.IsName || field.Attributes & FANavigation)) {
|
||||||
|
overrideGetParentsAffectingLogging = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (overrideGetParentsAffectingLogging) {
|
||||||
|
m_Header << "protected:" << std::endl << "\t";
|
||||||
|
|
||||||
|
if (klass.Name == "ConfigObject") {
|
||||||
|
m_Header << "virtual void GetParentsAffectingLogging(std::vector<intrusive_ptr<ConfigObject>>& output) const;";
|
||||||
|
} else {
|
||||||
|
m_Header << "void GetParentsAffectingLogging(std::vector<ConfigObject::Ptr>& output) const override;";
|
||||||
|
}
|
||||||
|
|
||||||
|
m_Header << std::endl;
|
||||||
|
|
||||||
|
m_Impl << "void ObjectImpl<" << klass.Name
|
||||||
|
<< ">::GetParentsAffectingLogging(std::vector<ConfigObject::Ptr>& output) const" << std::endl
|
||||||
|
<< "{" << std::endl;
|
||||||
|
|
||||||
|
std::set<std::string> types;
|
||||||
|
|
||||||
|
for (auto& field : klass.Fields) {
|
||||||
|
if (field.Attributes & FAParentAffectingLogging && field.Type.IsName && types.emplace(field.Type.TypeName).second) {
|
||||||
|
m_Impl << "\t" << "static const auto type" << field.Type.TypeName
|
||||||
|
<< " (Type::GetByName(\"" << field.Type.TypeName << "\"));" << std::endl
|
||||||
|
<< "\t" << "static const auto configType" << field.Type.TypeName
|
||||||
|
<< " (dynamic_cast<ConfigType*>(type" << field.Type.TypeName << ".get()));" << std::endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (klass.Name != "ConfigObject") {
|
||||||
|
m_Impl << std::endl << "\t" << klass.Parent << "::GetParentsAffectingLogging(output);" << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (auto& field : klass.Fields) {
|
||||||
|
if (field.Attributes & FAParentAffectingLogging && (field.Type.IsName || field.Attributes & FANavigation)) {
|
||||||
|
m_Impl << std::endl << "\t";
|
||||||
|
|
||||||
|
if (field.Type.IsName) {
|
||||||
|
if (field.Type.ArrayRank) {
|
||||||
|
m_Impl << "auto names" << field.GetFriendlyName()
|
||||||
|
<< " (Get" << field.GetFriendlyName() << "());" << std::endl << std::endl
|
||||||
|
<< "\t" << "if (names" << field.GetFriendlyName() << ") {" << std::endl
|
||||||
|
<< "\t\t" << "ObjectLock lock (names" << field.GetFriendlyName() << ");" << std::endl << std::endl
|
||||||
|
<< "\t\t" << "for (auto& name : names" << field.GetFriendlyName() << ") {" << std::endl
|
||||||
|
<< "\t\t\t" << "auto object (configType" << field.Type.TypeName << "->GetObject(name));" << std::endl << std::endl
|
||||||
|
<< "\t\t\t" << "if (object) {" << std::endl
|
||||||
|
<< "\t\t\t\t" << "output.emplace_back(std::move(object));" << std::endl
|
||||||
|
<< "\t\t\t" << "}" << std::endl
|
||||||
|
<< "\t\t" << "}";
|
||||||
|
} else {
|
||||||
|
m_Impl << "auto object" << field.GetFriendlyName()
|
||||||
|
<< " (configType" << field.Type.TypeName << "->GetObject(Get"
|
||||||
|
<< field.GetFriendlyName() << "()));" << std::endl << std::endl
|
||||||
|
<< "\t" << "if (object" << field.GetFriendlyName() << ") {" << std::endl
|
||||||
|
<< "\t\t" << "output.emplace_back(std::move(object" << field.GetFriendlyName() << "));";
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
m_Impl << "auto object" << field.GetFriendlyName()
|
||||||
|
<< " (static_pointer_cast<ConfigObject>(Navigate"
|
||||||
|
<< field.GetFriendlyName() << "()));" << std::endl << std::endl
|
||||||
|
<< "\t" << "if (object" << field.GetFriendlyName() << ") {" << std::endl
|
||||||
|
<< "\t\t" << "output.emplace_back(std::move(object" << field.GetFriendlyName() << "));";
|
||||||
|
}
|
||||||
|
|
||||||
|
m_Impl << std::endl << "\t" << "}" << std::endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
m_Impl << "}" << std::endl << std::endl;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (klass.Name == "ConfigObject")
|
if (klass.Name == "ConfigObject")
|
||||||
|
@ -62,6 +62,7 @@ enum FieldAttribute
|
|||||||
FASetVirtual = 16384,
|
FASetVirtual = 16384,
|
||||||
FAActivationPriority = 32768,
|
FAActivationPriority = 32768,
|
||||||
FASignalWithOldValue = 65536,
|
FASignalWithOldValue = 65536,
|
||||||
|
FAParentAffectingLogging = 131072,
|
||||||
};
|
};
|
||||||
|
|
||||||
struct FieldType
|
struct FieldType
|
||||||
|
Loading…
x
Reference in New Issue
Block a user