Skip to content

Commit

Permalink
Some refactor #207
Browse files Browse the repository at this point in the history
  • Loading branch information
nikkitashl committed Sep 7, 2022
1 parent d99eda3 commit 563ddb1
Show file tree
Hide file tree
Showing 22 changed files with 2,125 additions and 1,848 deletions.
1 change: 1 addition & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
BasedOnStyle: Google
Language: Cpp
ColumnLimit : 100
AccessModifierOffset: -4
AllowShortFunctionsOnASingleLine: None
AllowShortIfStatementsOnASingleLine: false
Expand Down
10 changes: 7 additions & 3 deletions remote_helper/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,14 @@ add_executable (${TARGET_NAME} remote_helper.cpp)
add_library(helper_lib STATIC)
target_sources(helper_lib
PRIVATE
git_utils.cpp
object_collector.cpp
git/git_utils.cpp
git/object_collector.cpp
utils.cpp
wallet_client.cpp
wallets/beam_wallet_client.cpp
engines/ipfs/ipfs_engine.cpp
engines/engine_factory.cpp
wallets/client_factory.cpp
engines/ipfs/types.cpp
)

target_include_directories(helper_lib PUBLIC ${LIBGIT2_INCLUDES})
Expand Down
53 changes: 53 additions & 0 deletions remote_helper/engines/base_engine.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
// Copyright 2021-2022 SOURC3 Team
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#pragma once

#include <string_view>
#include <vector>
#include <limits>

#include "utils.h"

struct IWalletClient;

struct IEngine {
enum struct CommandResult { Ok, Failed, Batch };

explicit IEngine(IWalletClient& client) : client_(client) {
}

virtual ~IEngine() = default;

virtual CommandResult DoCommand(std::string_view command,
std::vector<std::string_view>& args) = 0;

protected:
IWalletClient& client_;

struct BaseOptions {
enum struct SetResult { InvalidValue, Ok, Unsupported };

static constexpr uint32_t kInfiniteDepth =
(uint32_t)std::numeric_limits<int32_t>::max();
sourc3::ReporterType progress;
int64_t verbosity = 0;
uint32_t depth = kInfiniteDepth;

virtual ~BaseOptions() = default;

virtual SetResult Set(std::string_view option,
std::string_view value) = 0;
};
};
21 changes: 21 additions & 0 deletions remote_helper/engines/engine_factory.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Copyright 2021-2022 SOURC3 Team
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#include "engine_factory.h"

#include "engines/ipfs/ipfs_engine.h"

std::unique_ptr<IEngine> CreateEngine(IWalletClient& client) {
return std::make_unique<FullIPFSEngine>(client);
}
21 changes: 21 additions & 0 deletions remote_helper/engines/engine_factory.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Copyright 2021-2022 SOURC3 Team
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#pragma once

#include <memory>

#include "base_engine.h"

std::unique_ptr<IEngine> CreateEngine(IWalletClient& client);
Loading

0 comments on commit 563ddb1

Please sign in to comment.