Skip to content

Commit

Permalink
#5623: MergeAction type is now abstract
Browse files Browse the repository at this point in the history
  • Loading branch information
codereader committed May 24, 2021
1 parent 4eb10c4 commit c462f68
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 9 deletions.
1 change: 1 addition & 0 deletions libs/scene/CMakeLists.txt
Expand Up @@ -4,6 +4,7 @@ add_library(scenegraph
LayerUsageBreakdown.cpp
ModelFinder.cpp
Node.cpp
merge/MergeOperation.cpp
merge/GraphComparer.cpp
SelectableNode.cpp
SelectionIndex.cpp
Expand Down
17 changes: 13 additions & 4 deletions libs/scene/merge/MergeAction.h
@@ -1,5 +1,7 @@
#pragma once

#include <memory>

namespace scene
{

Expand All @@ -11,23 +13,30 @@ enum class ActionType

};

// Represents a single operation during a merge process
// There are various types of actions, i.e. brush addition,
// entity removal, keyvalue change, etc.
// Represents a single step of a merge process, like adding a brush,
// removing an entity, setting a keyvalue, etc.
class MergeAction
{
private:
ActionType _type;

public:
protected:
MergeAction(ActionType type) :
_type(type)
{}

public:
using Ptr = std::shared_ptr<MergeAction>;

ActionType getType() const
{
return _type;
}

// Applies this action, changing the nodes affecting by it
// It's the caller's responsibility to set up any Undo operations.
// Implementations are allowed to throw std::runtime_errors on failure.
virtual bool apply() = 0;
};


Expand Down
18 changes: 18 additions & 0 deletions libs/scene/merge/MergeOperation.cpp
@@ -0,0 +1,18 @@
#include "MergeOperation.h"

namespace scene
{

namespace merge
{

MergeOperation::Ptr MergeOperation::CreateFromComparisonResult(const ComparisonResult& comparisonResult)
{
// TODO

return std::make_shared<MergeOperation>();
}

}

}
7 changes: 2 additions & 5 deletions libs/scene/merge/MergeOperation.h
Expand Up @@ -16,15 +16,12 @@ namespace merge
class MergeOperation
{
private:
std::list<MergeAction> _actions;
std::list<MergeAction::Ptr> _actions;

public:
using Ptr = std::shared_ptr<MergeOperation>;

static MergeOperation::Ptr CreateFromComparisonResult(const ComparisonResult& comparisonResult)
{
return std::make_shared<MergeOperation>();
}
static MergeOperation::Ptr CreateFromComparisonResult(const ComparisonResult& comparisonResult);
};

}
Expand Down
1 change: 1 addition & 0 deletions tools/msvc/scenelib.vcxproj
Expand Up @@ -118,6 +118,7 @@
<ClCompile Include="..\..\libs\scene\InstanceWalkers.cpp" />
<ClCompile Include="..\..\libs\scene\LayerUsageBreakdown.cpp" />
<ClCompile Include="..\..\libs\scene\merge\GraphComparer.cpp" />
<ClCompile Include="..\..\libs\scene\merge\MergeOperation.cpp" />
<ClCompile Include="..\..\libs\scene\ModelFinder.cpp" />
<ClCompile Include="..\..\libs\scene\Node.cpp" />
<ClCompile Include="..\..\libs\scene\SelectableNode.cpp" />
Expand Down
3 changes: 3 additions & 0 deletions tools/msvc/scenelib.vcxproj.filters
Expand Up @@ -39,6 +39,9 @@
<ClCompile Include="..\..\libs\scene\merge\GraphComparer.cpp">
<Filter>scene\merge</Filter>
</ClCompile>
<ClCompile Include="..\..\libs\scene\merge\MergeOperation.cpp">
<Filter>scene\merge</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\libs\scene\InstanceWalkers.h">
Expand Down

0 comments on commit c462f68

Please sign in to comment.