Skip to content

Commit

Permalink
added multiinstances stub module
Browse files Browse the repository at this point in the history
  • Loading branch information
igorkorsukov authored and vpereverzev committed Jun 18, 2021
1 parent f0ebf09 commit c1d5fa9
Show file tree
Hide file tree
Showing 10 changed files with 265 additions and 1 deletion.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ option(BUILD_PALETTE_MODULE "Build palette module" ON)
option(BUILD_INSTRUMENTS_MODULE "Build instruments module" ON)
option(BUILD_INSPECTOR_MODULE "Build inspector module" ON)
option(BUILD_AUTOBOT_MODULE "Build autobot module" OFF)
option(BUILD_MULTIINSTANCES_MODULE "Build multiinstances module" OFF) # Temporary off

option(USE_SCORE_ACCESSIBLE_TREE "Use score accessible tree" OFF)

Expand Down
1 change: 1 addition & 0 deletions build/config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
#cmakedefine BUILD_INSTRUMENTS_MODULE
#cmakedefine BUILD_INSPECTOR_MODULE
#cmakedefine BUILD_AUTOBOT_MODULE
#cmakedefine BUILD_MULTIINSTANCES_MODULE
#cmakedefine BUILD_VST

#cmakedefine USE_SCORE_ACCESSIBLE_TREE
Expand Down
4 changes: 3 additions & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,9 @@ if (BUILD_INSPECTOR_MODULE)
endif (BUILD_INSPECTOR_MODULE)

# Other
add_subdirectory(multiinstances)
if (BUILD_MULTIINSTANCES_MODULE)
add_subdirectory(multiinstances)
endif()

if (BUILD_AUTOBOT_MODULE)
add_subdirectory(autobot)
Expand Down
4 changes: 4 additions & 0 deletions src/main/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,11 @@
#include "stubs/languages/languagesstubmodule.h"
#endif

#ifdef BUILD_MULTIINSTANCES_MODULE
#include "multiinstances/multiinstancesmodule.h"
#else
#include "stubs/multiinstances/multiinstancesstubmodule.h"
#endif

#ifdef BUILD_AUTOBOT_MODULE
#include "autobot/autobotmodule.h"
Expand Down
4 changes: 4 additions & 0 deletions src/stubs/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,7 @@ endif (NOT BUILD_INSTRUMENTS_MODULE)
if (NOT BUILD_INSPECTOR_MODULE)
add_subdirectory(inspector)
endif (NOT BUILD_INSPECTOR_MODULE)

if (NOT BUILD_MULTIINSTANCES_MODULE)
add_subdirectory(multiinstances)
endif()
31 changes: 31 additions & 0 deletions src/stubs/multiinstances/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# SPDX-License-Identifier: GPL-3.0-only
# MuseScore-CLA-applies
#
# MuseScore
# Music Composition & Notation
#
# Copyright (C) 2021 MuseScore BVBA and others
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 3 as
# published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.

set(MODULE multiinstances)

set(MODULE_SRC
${CMAKE_CURRENT_LIST_DIR}/multiinstancesstubmodule.cpp
${CMAKE_CURRENT_LIST_DIR}/multiinstancesstubmodule.h
${CMAKE_CURRENT_LIST_DIR}/multiinstancesstubprovider.cpp
${CMAKE_CURRENT_LIST_DIR}/multiinstancesstubprovider.h
)

include(${PROJECT_SOURCE_DIR}/build/module.cmake)

38 changes: 38 additions & 0 deletions src/stubs/multiinstances/multiinstancesstubmodule.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* SPDX-License-Identifier: GPL-3.0-only
* MuseScore-CLA-applies
*
* MuseScore
* Music Composition & Notation
*
* Copyright (C) 2021 MuseScore BVBA and others
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 3 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#include "multiinstancesstubmodule.h"

#include "modularity/ioc.h"
#include "multiinstancesstubprovider.h"

using namespace mu::mi;
using namespace mu::framework;

std::string MultiInstancesModule::moduleName() const
{
return "multiinstances_stub";
}

void MultiInstancesModule::registerExports()
{
ioc()->registerExport<IMultiInstancesProvider>(moduleName(), new MultiInstancesStubProvider());
}
37 changes: 37 additions & 0 deletions src/stubs/multiinstances/multiinstancesstubmodule.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* SPDX-License-Identifier: GPL-3.0-only
* MuseScore-CLA-applies
*
* MuseScore
* Music Composition & Notation
*
* Copyright (C) 2021 MuseScore BVBA and others
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 3 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef MU_MI_MULTIINSTANCESSTUBMODULE_H
#define MU_MI_MULTIINSTANCESSTUBMODULE_H

#include "modularity/imodulesetup.h"

namespace mu::mi {
class MultiInstancesModule : public framework::IModuleSetup
{
public:
std::string moduleName() const override;

void registerExports() override;
};
}

#endif // MU_MI_MULTIINSTANCESSTUBMODULE_H
90 changes: 90 additions & 0 deletions src/stubs/multiinstances/multiinstancesstubprovider.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
/*
* SPDX-License-Identifier: GPL-3.0-only
* MuseScore-CLA-applies
*
* MuseScore
* Music Composition & Notation
*
* Copyright (C) 2021 MuseScore BVBA and others
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 3 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#include "multiinstancesstubprovider.h"

using namespace mu::mi;

// Score opening
bool MultiInstancesStubProvider::isScoreAlreadyOpened(const io::path&) const
{
return false;
}

void MultiInstancesStubProvider::activateWindowWithScore(const io::path&)
{
}

// Settings
bool MultiInstancesStubProvider::isPreferencesAlreadyOpened() const
{
return false;
}

void MultiInstancesStubProvider::activateWindowWithOpenedPreferences() const
{
}

void MultiInstancesStubProvider::settingsBeginTransaction()
{
}

void MultiInstancesStubProvider::settingsCommitTransaction()
{
}

void MultiInstancesStubProvider::settingsRollbackTransaction()
{
}

void MultiInstancesStubProvider::settingsSetValue(const std::string&, const Val&)
{
}

// Resources (files)
bool MultiInstancesStubProvider::lockResource(const std::string&)
{
return true;
}

bool MultiInstancesStubProvider::unlockResource(const std::string&)
{
return true;
}

// Instances info
const std::string& MultiInstancesStubProvider::selfID() const
{
static std::string id("stub");
return id;
}

std::vector<InstanceMeta> MultiInstancesStubProvider::instances() const
{
static std::vector<InstanceMeta> v;
return v;
}

mu::async::Notification MultiInstancesStubProvider::instancesChanged() const
{
static mu::async::Notification n;
return n;
}
56 changes: 56 additions & 0 deletions src/stubs/multiinstances/multiinstancesstubprovider.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*
* SPDX-License-Identifier: GPL-3.0-only
* MuseScore-CLA-applies
*
* MuseScore
* Music Composition & Notation
*
* Copyright (C) 2021 MuseScore BVBA and others
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 3 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef MU_MI_MULTIINSTANCESSTUBPROVIDER_H
#define MU_MI_MULTIINSTANCESSTUBPROVIDER_H

#include "multiinstances/imultiinstancesprovider.h"

namespace mu::mi {
class MultiInstancesStubProvider : public IMultiInstancesProvider
{
public:
MultiInstancesStubProvider() = default;

// Score opening
bool isScoreAlreadyOpened(const io::path& scorePath) const override;
void activateWindowWithScore(const io::path& scorePath) override;

// Settings
bool isPreferencesAlreadyOpened() const override;
void activateWindowWithOpenedPreferences() const override;
void settingsBeginTransaction() override;
void settingsCommitTransaction() override;
void settingsRollbackTransaction() override;
void settingsSetValue(const std::string& key, const Val& value) override;

// Resources (files)
bool lockResource(const std::string& name) override;
bool unlockResource(const std::string& name) override;

// Instances info
const std::string& selfID() const override;
std::vector<InstanceMeta> instances() const override;
async::Notification instancesChanged() const override;
};
}

#endif // MU_MI_MULTIINSTANCESSTUBPROVIDER_H

0 comments on commit c1d5fa9

Please sign in to comment.