Skip to content

Commit

Permalink
refactor: rename keynodes class
Browse files Browse the repository at this point in the history
  • Loading branch information
MksmOrlov committed Mar 28, 2024
1 parent 3b5e553 commit 6a94843
Show file tree
Hide file tree
Showing 15 changed files with 59 additions and 91 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ set(HEADERS
"agent/remove_section_agent.hpp"
"builder/subject_domain_builder.hpp"
"constants/subject_domain_aliases.hpp"
"constants/sc_search_aliases.hpp"
"generator/subject_domain_generator.hpp"
"keynodes/subject_domain_keynodes.hpp"
"utils/set_utils.hpp"
Expand All @@ -18,7 +17,6 @@ set(SOURCES
"agent/remove_section_agent.cpp"
"builder/subject_domain_builder.cpp"
"constants/subject_domain_aliases.cpp"
"constants/sc_search_aliases.cpp"
"generator/subject_domain_generator.cpp"
"keynodes/subject_domain_keynodes.cpp"
"utils/set_utils.cpp"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ SC_AGENT_IMPLEMENTATION(AddSectionAgent)
bool AddSectionAgent::CheckActionClass(ScAddr const & actionNode)
{
return m_memoryCtx.HelperCheckEdge(
subject_domain_keynodes::action_add_section, actionNode, ScType::EdgeAccessConstPosPerm);
SubjectDomainKeynodes::action_add_section, actionNode, ScType::EdgeAccessConstPosPerm);
}

ScAddr AddSectionAgent::GenerateSection(
Expand Down Expand Up @@ -108,7 +108,7 @@ ScAddr AddSectionAgent::GenerateSection(
ScType::EdgeAccessConstPosPerm,
lastSection,
ScType::EdgeAccessConstPosTemp,
subject_domain_keynodes::rrel_last);
SubjectDomainKeynodes::rrel_last);
if (lastSectionIterator->Next())
{
ScAddr previousSectionArc = lastSectionIterator->Get(1);
Expand All @@ -117,19 +117,19 @@ ScAddr AddSectionAgent::GenerateSection(

utils::GenerationUtils::generateRelationBetween(
&m_memoryCtx, previousSectionArc, newSectionArc, CoreKeynodes::nrel_basic_sequence);
m_memoryCtx.CreateEdge(ScType::EdgeAccessConstPosTemp, subject_domain_keynodes::rrel_last, newSectionArc);
m_memoryCtx.CreateEdge(ScType::EdgeAccessConstPosTemp, SubjectDomainKeynodes::rrel_last, newSectionArc);
}
}
else
{
SC_LOG_DEBUG("AddSectionAgent: added section is new.");
m_memoryCtx.CreateEdge(ScType::EdgeAccessConstPosPerm, CoreKeynodes::rrel_1, newSectionArc);
m_memoryCtx.CreateEdge(ScType::EdgeAccessConstPosTemp, subject_domain_keynodes::rrel_last, newSectionArc);
m_memoryCtx.CreateEdge(ScType::EdgeAccessConstPosTemp, SubjectDomainKeynodes::rrel_last, newSectionArc);
}

subjectDomainModule::SetUtils::AddToSets(&m_memoryCtx, parentSection, {subject_domain_keynodes::non_atomic_section});
subjectDomainModule::SetUtils::RemoveFromSets(&m_memoryCtx, parentSection, {subject_domain_keynodes::atomic_section});
subjectDomainModule::SetUtils::RemoveFromSets(&m_memoryCtx, newSection, {subject_domain_keynodes::removed_section});
subjectDomainModule::SetUtils::AddToSets(&m_memoryCtx, parentSection, {SubjectDomainKeynodes::non_atomic_section});
subjectDomainModule::SetUtils::RemoveFromSets(&m_memoryCtx, parentSection, {SubjectDomainKeynodes::atomic_section});
subjectDomainModule::SetUtils::RemoveFromSets(&m_memoryCtx, newSection, {SubjectDomainKeynodes::removed_section});
return newSection;
}

Expand All @@ -139,7 +139,7 @@ ScAddr AddSectionAgent::GenerateSection(std::string const & sectionName, ScAddr
if (!m_memoryCtx.IsElement(section))
section = subject_domain_generator::GenerateSection(&m_memoryCtx, sectionName, lang, true);
else
subjectDomainModule::SetUtils::RemoveFromSets(&m_memoryCtx, section, {subject_domain_keynodes::removed_section});
subjectDomainModule::SetUtils::RemoveFromSets(&m_memoryCtx, section, {SubjectDomainKeynodes::removed_section});
return section;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
* (See accompanying file COPYING.MIT or copy at http://opensource.org/licenses/MIT)
*/

#include "constants/sc_search_aliases.hpp"
#include "sc-agents-common/utils/AgentUtils.hpp"
#include "sc-agents-common/utils/CommonUtils.hpp"
#include "sc-agents-common/utils/IteratorUtils.hpp"

#include "keynodes/subject_domain_keynodes.hpp"

#include "get_decomposition_agent.hpp"
#include "constants/subject_domain_aliases.hpp"

using namespace utils;

Expand Down Expand Up @@ -51,7 +51,7 @@ SC_AGENT_IMPLEMENTATION(GetDecompositionAgent)
}
if (!m_memoryCtx.IsElement(decompositionAddr))
{
decompositionAddr = subjectDomainModule::subject_domain_keynodes::nrel_section_decomposition;
decompositionAddr = SubjectDomainKeynodes::nrel_section_decomposition;
SC_LOG_DEBUG(
"GetDecompositionAgent: decomposition relation node not found. By default, "
<< m_memoryCtx.HelperGetSystemIdtf(decompositionAddr) << " is used.");
Expand Down Expand Up @@ -80,7 +80,7 @@ SC_AGENT_IMPLEMENTATION(GetDecompositionAgent)
bool GetDecompositionAgent::CheckActionClass(ScAddr const & actionNode)
{
return m_memoryCtx.HelperCheckEdge(
subject_domain_keynodes::action_get_decomposition, actionNode, ScType::EdgeAccessConstPosPerm);
SubjectDomainKeynodes::action_get_decomposition, actionNode, ScType::EdgeAccessConstPosPerm);
}

ScAddrVector GetDecompositionAgent::GetDecomposition(ScAddr const & subjDomainAddr, ScAddr const & decompositionAddr)
Expand All @@ -90,23 +90,23 @@ ScAddrVector GetDecompositionAgent::GetDecomposition(ScAddr const & subjDomainAd

ScTemplate decompositionTemplate;
decompositionTemplate.Quintuple(
ScType::NodeVar >> sc_search_aliases::DECOMPOSITION_TUPLE,
ScType::NodeVar >> subject_domain_aliases::DECOMPOSITION_TUPLE,
ScType::EdgeDCommonVar,
subjDomainAddr,
ScType::EdgeAccessVarPosPerm,
decompositionAddr);
decompositionTemplate.Quintuple(
sc_search_aliases::DECOMPOSITION_TUPLE,
subject_domain_aliases::DECOMPOSITION_TUPLE,
ScType::EdgeAccessVarPosPerm,
ScType::NodeVar >> sc_search_aliases::SECTION_NODE,
ScType::NodeVar >> subject_domain_aliases::SECTION_NODE,
ScType::EdgeAccessVarPosPerm,
scAgentsCommon::CoreKeynodes::rrel_1);
ScTemplateSearchResult result;
m_memoryCtx.HelperSearchTemplate(decompositionTemplate, result);
if (!result.IsEmpty())
{
ScAddr tupleNode = result[0][sc_search_aliases::DECOMPOSITION_TUPLE];
ScAddr subSection = result[0][sc_search_aliases::SECTION_NODE];
ScAddr tupleNode = result[0][subject_domain_aliases::DECOMPOSITION_TUPLE];
ScAddr subSection = result[0][subject_domain_aliases::SECTION_NODE];
SC_LOG_DEBUG("GetDecompositionAgent: subsection is " << m_memoryCtx.HelperGetSystemIdtf(subSection) << ".");
decomposition.push_back(subSection);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ SC_AGENT_IMPLEMENTATION(RemoveSectionAgent)
bool RemoveSectionAgent::CheckActionClass(ScAddr const & actionNode)
{
return m_memoryCtx.HelperCheckEdge(
subject_domain_keynodes::action_remove_section, actionNode, ScType::EdgeAccessConstPosPerm);
SubjectDomainKeynodes::action_remove_section, actionNode, ScType::EdgeAccessConstPosPerm);
}

bool RemoveSectionAgent::RemoveSection(ScAddr const & section, ScAddr const & parentSection)
Expand All @@ -76,7 +76,7 @@ bool RemoveSectionAgent::RemoveSection(ScAddr const & section, ScAddr const & pa
{
HandleSection(searchResult[0], section);
HandleParentSection(searchResult[0], parentSection);
subjectDomainModule::SetUtils::AddToSets(&m_memoryCtx, section, {subject_domain_keynodes::removed_section});
subjectDomainModule::SetUtils::AddToSets(&m_memoryCtx, section, {SubjectDomainKeynodes::removed_section});

return true;
}
Expand All @@ -101,12 +101,12 @@ bool RemoveSectionAgent::RemoveSection(ScAddr const & section)
HandleSection(searchResult[i], section);
HandleParentSection(searchResult[i], parentSection);
}
subjectDomainModule::SetUtils::AddToSets(&m_memoryCtx, section, {subject_domain_keynodes::removed_section});
subjectDomainModule::SetUtils::AddToSets(&m_memoryCtx, section, {SubjectDomainKeynodes::removed_section});

return true;
}
ScAddr edge =
m_memoryCtx.CreateEdge(ScType::EdgeAccessConstPosPerm, subject_domain_keynodes::removed_section, section);
m_memoryCtx.CreateEdge(ScType::EdgeAccessConstPosPerm, SubjectDomainKeynodes::removed_section, section);
return m_memoryCtx.IsElement(edge);
}

Expand All @@ -126,9 +126,9 @@ void RemoveSectionAgent::HandleParentSection(
if (CommonUtils::getSetPower(&m_memoryCtx, tuple) == 0)
{
m_memoryCtx.EraseElement(tuple);
subjectDomainModule::SetUtils::AddToSets(&m_memoryCtx, parentSection, {subject_domain_keynodes::atomic_section});
subjectDomainModule::SetUtils::AddToSets(&m_memoryCtx, parentSection, {SubjectDomainKeynodes::atomic_section});
subjectDomainModule::SetUtils::RemoveFromSets(
&m_memoryCtx, parentSection, {subject_domain_keynodes::non_atomic_section});
&m_memoryCtx, parentSection, {SubjectDomainKeynodes::non_atomic_section});
}
}

Expand Down Expand Up @@ -190,7 +190,7 @@ void RemoveSectionAgent::HandleNeighboringSections(ScAddr const & tuple, ScAddr
// If current element is the last
if (m_memoryCtx.IsElement(previousSection) && !m_memoryCtx.IsElement(nextSection))
{
m_memoryCtx.CreateEdge(ScType::EdgeAccessConstPosTemp, subject_domain_keynodes::rrel_last, previousSectionEdge);
m_memoryCtx.CreateEdge(ScType::EdgeAccessConstPosTemp, SubjectDomainKeynodes::rrel_last, previousSectionEdge);
}

// If current element is the first
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ void subject_domain_builder::buildDecompositionTupleTemplate(
ScType::EdgeDCommonVar,
parentSection,
ScType::EdgeAccessVarPosPerm,
subject_domain_keynodes::nrel_entity_decomposition);
SubjectDomainKeynodes::nrel_entity_decomposition);
scTemplate.Triple(
subject_domain_aliases::DECOMPOSITION_TUPLE,
ScType::EdgeAccessVarPosPerm >> subject_domain_aliases::EDGE_TO_DELETE,
Expand All @@ -37,7 +37,7 @@ void subject_domain_builder::buildDecompositionTupleTemplate(ScTemplate & scTemp
ScType::EdgeDCommonVar,
ScType::NodeVar >> subject_domain_aliases::PARENT_SECTION,
ScType::EdgeAccessVarPosPerm,
subject_domain_keynodes::nrel_entity_decomposition);
SubjectDomainKeynodes::nrel_entity_decomposition);
scTemplate.Triple(
subject_domain_aliases::DECOMPOSITION_TUPLE,
ScType::EdgeAccessVarPosPerm >> subject_domain_aliases::EDGE_TO_DELETE,
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ ScAddr subject_domain_generator::GenerateSection(
utils::CommonUtils::setMainIdtf(context, section, sectionName, {lang});

ScTemplate sectionTemplate;
sectionTemplate.Triple(subject_domain_keynodes::section, ScType::EdgeAccessVarPosPerm, section);
sectionTemplate.Triple(SubjectDomainKeynodes::section, ScType::EdgeAccessVarPosPerm, section);
if (isAtomic)
sectionTemplate.Triple(subject_domain_keynodes::atomic_section, ScType::EdgeAccessVarPosPerm, section);
sectionTemplate.Triple(SubjectDomainKeynodes::atomic_section, ScType::EdgeAccessVarPosPerm, section);
else
sectionTemplate.Triple(subject_domain_keynodes::non_atomic_section, ScType::EdgeAccessVarPosPerm, section);
sectionTemplate.Triple(subject_domain_keynodes::not_enough_formed_structure, ScType::EdgeAccessVarPosPerm, section);
sectionTemplate.Triple(SubjectDomainKeynodes::non_atomic_section, ScType::EdgeAccessVarPosPerm, section);
sectionTemplate.Triple(SubjectDomainKeynodes::not_enough_formed_structure, ScType::EdgeAccessVarPosPerm, section);
ScTemplateGenResult genResult;
context->HelperGenTemplate(sectionTemplate, genResult);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@

namespace subjectDomainModule
{
ScAddr subject_domain_keynodes::action_get_decomposition;
ScAddr subject_domain_keynodes::action_add_section;
ScAddr subject_domain_keynodes::action_remove_section;
ScAddr subject_domain_keynodes::nrel_section_decomposition;
ScAddr subject_domain_keynodes::nrel_entity_decomposition;
ScAddr subject_domain_keynodes::removed_section;
ScAddr subject_domain_keynodes::section;
ScAddr subject_domain_keynodes::not_enough_formed_structure;
ScAddr subject_domain_keynodes::atomic_section;
ScAddr subject_domain_keynodes::non_atomic_section;
ScAddr subject_domain_keynodes::rrel_last;
ScAddr SubjectDomainKeynodes::action_get_decomposition;
ScAddr SubjectDomainKeynodes::action_add_section;
ScAddr SubjectDomainKeynodes::action_remove_section;
ScAddr SubjectDomainKeynodes::nrel_section_decomposition;
ScAddr SubjectDomainKeynodes::nrel_entity_decomposition;
ScAddr SubjectDomainKeynodes::removed_section;
ScAddr SubjectDomainKeynodes::section;
ScAddr SubjectDomainKeynodes::not_enough_formed_structure;
ScAddr SubjectDomainKeynodes::atomic_section;
ScAddr SubjectDomainKeynodes::non_atomic_section;
ScAddr SubjectDomainKeynodes::rrel_last;
} // namespace subjectDomainModule
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

namespace subjectDomainModule
{
class subject_domain_keynodes : public ScObject
class SubjectDomainKeynodes : public ScObject
{
SC_CLASS()
SC_GENERATED_BODY()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ SC_IMPLEMENT_MODULE(SubjectDomainModule)

sc_result SubjectDomainModule::InitializeImpl()
{
if (!subjectDomainModule::subject_domain_keynodes::InitGlobal())
if (!subjectDomainModule::SubjectDomainKeynodes::InitGlobal())
return SC_RESULT_ERROR;

SC_AGENT_REGISTER(GetDecompositionAgent)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ TEST_F(AddSectionDomainTest, successful_add_section_to_decomposition)
{
ScMemoryContext & context = *m_ctx;
scAgentsCommon::CoreKeynodes::InitGlobal();
subject_domain_keynodes::InitGlobal();
SubjectDomainKeynodes::InitGlobal();
SC_AGENT_REGISTER(AddSectionAgent)
ScsLoader loader;
loader.loadScsFile(context, TEST_FILES_DIR_PATH + "test_add_section.scs");
Expand Down Expand Up @@ -68,7 +68,7 @@ TEST_F(AddSectionDomainTest, successful_add_section_empty_decomposition)
{
ScMemoryContext & context = *m_ctx;
scAgentsCommon::CoreKeynodes::InitGlobal();
subject_domain_keynodes::InitGlobal();
SubjectDomainKeynodes::InitGlobal();

SC_AGENT_REGISTER(AddSectionAgent)
ScsLoader loader;
Expand Down Expand Up @@ -100,7 +100,7 @@ TEST_F(AddSectionDomainTest, add_section_invalid_parameters_1)
{
ScMemoryContext & context = *m_ctx;
scAgentsCommon::CoreKeynodes::InitGlobal();
subject_domain_keynodes::InitGlobal();
SubjectDomainKeynodes::InitGlobal();

SC_AGENT_REGISTER(AddSectionAgent)
ScsLoader loader;
Expand All @@ -118,7 +118,7 @@ TEST_F(AddSectionDomainTest, add_section_invalid_parameters_3)
{
ScMemoryContext & context = *m_ctx;
scAgentsCommon::CoreKeynodes::InitGlobal();
subject_domain_keynodes::InitGlobal();
SubjectDomainKeynodes::InitGlobal();

SC_AGENT_REGISTER(AddSectionAgent)
ScsLoader loader;
Expand All @@ -136,7 +136,7 @@ TEST_F(AddSectionDomainTest, add_section_without_parent)
{
ScMemoryContext & context = *m_ctx;
scAgentsCommon::CoreKeynodes::InitGlobal();
subject_domain_keynodes::InitGlobal();
SubjectDomainKeynodes::InitGlobal();

SC_AGENT_REGISTER(AddSectionAgent)
ScsLoader loader;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ using AddSectionDomainTest = ScMemoryTest;
void initialize()
{
scAgentsCommon::CoreKeynodes::InitGlobal();
subject_domain_keynodes::InitGlobal();
SubjectDomainKeynodes::InitGlobal();

SC_AGENT_REGISTER(GetDecompositionAgent)
}
Expand Down
Loading

0 comments on commit 6a94843

Please sign in to comment.