added base interfaces for notation export

This commit is contained in:
Roman Pudashkin 2020-11-10 13:34:21 +02:00 committed by pereverzev+v
parent bad7dbe914
commit 7b60f2e44f
14 changed files with 290 additions and 22 deletions

View file

@ -24,6 +24,7 @@ set(MODULE_SRC
${CMAKE_CURRENT_LIST_DIR}/systemmodule.h
${CMAKE_CURRENT_LIST_DIR}/systemerrors.h
${CMAKE_CURRENT_LIST_DIR}/ifilesystem.h
${CMAKE_CURRENT_LIST_DIR}/iodevice.h
${CMAKE_CURRENT_LIST_DIR}/internal/filesystem.cpp
${CMAKE_CURRENT_LIST_DIR}/internal/filesystem.h
)

View file

@ -0,0 +1,28 @@
//=============================================================================
// MuseScore
// Music Composition & Notation
//
// Copyright (C) 2020 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 2.
//
// 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, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//=============================================================================
#ifndef MU_FRAMEWORK_IODEVICE_H
#define MU_FRAMEWORK_IODEVICE_H
#include <QIODevice>
namespace mu::framework {
using IODevice = QIODevice;
}
#endif // MU_FRAMEWORK_IODEVICE_H

View file

@ -35,6 +35,10 @@ set(MODULE_SRC
${CMAKE_CURRENT_LIST_DIR}/inotation.h
${CMAKE_CURRENT_LIST_DIR}/inotationreader.h
${CMAKE_CURRENT_LIST_DIR}/inotationreadersregister.h
${CMAKE_CURRENT_LIST_DIR}/inotationwriter.h
${CMAKE_CURRENT_LIST_DIR}/inotationwritersregister.h
${CMAKE_CURRENT_LIST_DIR}/abstractnotationwriter.h
${CMAKE_CURRENT_LIST_DIR}/internal/abstractnotationwriter.cpp
${CMAKE_CURRENT_LIST_DIR}/inotationcreator.h
${CMAKE_CURRENT_LIST_DIR}/inotationinputstate.h
${CMAKE_CURRENT_LIST_DIR}/inotationselection.h
@ -83,6 +87,8 @@ set(MODULE_SRC
${CMAKE_CURRENT_LIST_DIR}/internal/mscznotationreader.h
${CMAKE_CURRENT_LIST_DIR}/internal/notationreadersregister.cpp
${CMAKE_CURRENT_LIST_DIR}/internal/notationreadersregister.h
${CMAKE_CURRENT_LIST_DIR}/internal/notationwritersregister.cpp
${CMAKE_CURRENT_LIST_DIR}/internal/notationwritersregister.h
${CMAKE_CURRENT_LIST_DIR}/internal/msczmetareader.cpp
${CMAKE_CURRENT_LIST_DIR}/internal/msczmetareader.h
${CMAKE_CURRENT_LIST_DIR}/internal/notationplayback.cpp

View file

@ -0,0 +1,37 @@
//=============================================================================
// MuseScore
// Music Composition & Notation
//
// Copyright (C) 2020 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 2.
//
// 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, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//=============================================================================
#ifndef MU_NOTATION_ABSTRACTNOTATIONWRITER_H
#define MU_NOTATION_ABSTRACTNOTATIONWRITER_H
#include "inotationwriter.h"
namespace mu::notation {
class AbstractNotationWriter : public INotationWriter
{
public:
void abort() override;
async::Channel<framework::Progress> progress() const override;
private:
async::Channel<framework::Progress> m_progress;
};
}
#endif // MU_NOTATION_NOTATIONWRITERSREGISTER_H

View file

@ -28,8 +28,7 @@ namespace Ms {
class MasterScore;
}
namespace mu {
namespace notation {
namespace mu::notation {
class INotationReader
{
public:
@ -40,6 +39,5 @@ public:
using INotationReaderPtr = std::shared_ptr<INotationReader>;
}
}
#endif // MU_NOTATION_INOTATIONREADER_H

View file

@ -25,20 +25,19 @@
#include "modularity/imoduleexport.h"
#include "inotationreader.h"
namespace mu {
namespace notation {
namespace mu::notation {
class INotationReadersRegister : MODULE_EXPORT_INTERFACE
{
INTERFACE_ID(INotationReadersRegister)
public:
virtual ~INotationReadersRegister() = default;
//! NOTE In the future, we need to replace the suffix with an enumerator
//! or a better structure describing the format.
virtual void reg(const std::vector<std::string>& syffixs, std::shared_ptr<INotationReader> reader) = 0;
virtual std::shared_ptr<INotationReader> reader(const std::string& syffix) = 0;
virtual void reg(const std::vector<std::string>& suffixes, INotationReaderPtr reader) = 0;
virtual INotationReaderPtr reader(const std::string& suffix) = 0;
};
}
}
#endif // MU_NOTATION_INOTATIONREADERSREGISTER_H

View file

@ -0,0 +1,49 @@
//=============================================================================
// MuseScore
// Music Composition & Notation
//
// Copyright (C) 2020 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 2.
//
// 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, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//=============================================================================
#ifndef MU_NOTATION_INOTATIONWRITER_H
#define MU_NOTATION_INOTATIONWRITER_H
#include "ret.h"
#include "async/channel.h"
#include "network/networktypes.h"
#include "system/iodevice.h"
namespace Ms {
class Score;
}
namespace mu::notation {
class INotationWriter
{
public:
using Options = std::map<std::string, std::string>;
virtual ~INotationWriter() = default;
virtual Ret write(const Ms::Score& score, framework::IODevice& destinationDevice, const Options& options = Options()) = 0;
virtual void abort() = 0;
virtual async::Channel<framework::Progress> progress() const = 0;
};
using INotationWriterPtr = std::shared_ptr<INotationWriter>;
}
#endif // MU_NOTATION_INOTATIONWRITER_H

View file

@ -0,0 +1,39 @@
//=============================================================================
// MuseScore
// Music Composition & Notation
//
// Copyright (C) 2020 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 2.
//
// 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, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//=============================================================================
#ifndef MU_NOTATION_INOTATIONWRITERSREGISTER_H
#define MU_NOTATION_INOTATIONWRITERSREGISTER_H
#include "modularity/imoduleexport.h"
#include "inotationwriter.h"
namespace mu::notation {
class INotationWritersRegister : MODULE_EXPORT_INTERFACE
{
INTERFACE_ID(INotationWritersRegister)
public:
virtual ~INotationWritersRegister() = default;
virtual void reg(const std::vector<std::string>& suffixes, INotationWriterPtr writer) = 0;
virtual INotationWriterPtr writer(const std::string& suffix) const = 0;
};
}
#endif // MU_NOTATION_INOTATIONWRITERSREGISTER_H

View file

@ -0,0 +1,36 @@
//=============================================================================
// MuseScore
// Music Composition & Notation
//
// Copyright (C) 2020 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 2.
//
// 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, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//=============================================================================
#include "../abstractnotationwriter.h"
#include "log.h"
using namespace mu::notation;
using namespace mu::async;
using namespace mu::framework;
void AbstractNotationWriter::abort()
{
NOT_IMPLEMENTED;
}
Channel<Progress> AbstractNotationWriter::progress() const
{
return m_progress;
}

View file

@ -20,8 +20,10 @@
#define MU_NOTATION_MASTERNOTATION_H
#include "../imasternotation.h"
#include "modularity/ioc.h"
#include "../inotationreadersregister.h"
#include "../inotationwritersregister.h"
#include "modularity/ioc.h"
#include "notation.h"
#include "retval.h"
@ -33,6 +35,7 @@ namespace mu::notation {
class MasterNotation : public IMasterNotation, public Notation
{
INJECT(notation, INotationReadersRegister, readers)
INJECT(notation, INotationWritersRegister, writers)
public:
explicit MasterNotation();

View file

@ -20,16 +20,16 @@
using namespace mu::notation;
void NotationReadersRegister::reg(const std::vector<std::string>& syffixs, std::shared_ptr<INotationReader> reader)
void NotationReadersRegister::reg(const std::vector<std::string>& suffixs, INotationReaderPtr reader)
{
for (const std::string& s : syffixs) {
m_readers.insert({ s, reader });
for (const std::string& suffix : suffixs) {
m_readers.insert({ suffix, reader });
}
}
std::shared_ptr<INotationReader> NotationReadersRegister::reader(const std::string& syffix)
INotationReaderPtr NotationReadersRegister::reader(const std::string& suffix)
{
auto it = m_readers.find(syffix);
auto it = m_readers.find(suffix);
if (it != m_readers.end()) {
return it->second;
}

View file

@ -22,20 +22,16 @@
#include <map>
#include "../inotationreadersregister.h"
namespace mu {
namespace notation {
namespace mu::notation {
class NotationReadersRegister : public INotationReadersRegister
{
public:
void reg(const std::vector<std::string>& syffixs, std::shared_ptr<INotationReader> reader) override;
std::shared_ptr<INotationReader> reader(const std::string& syffix) override;
void reg(const std::vector<std::string>& suffixes, INotationReaderPtr reader) override;
INotationReaderPtr reader(const std::string& suffix) override;
private:
std::map<std::string, std::shared_ptr<INotationReader> > m_readers;
std::map<std::string, INotationReaderPtr> m_readers;
};
}
}
#endif // MU_NOTATION_NOTATIONREADERSREGISTER_H

View file

@ -0,0 +1,39 @@
//=============================================================================
// MuseScore
// Music Composition & Notation
//
// Copyright (C) 2020 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 2.
//
// 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, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//=============================================================================
#include "notationwritersregister.h"
using namespace mu::notation;
void NotationWritersRegister::reg(const std::vector<std::string>& suffixes, INotationWriterPtr writer)
{
for (const std::string& suffix : suffixes) {
m_writers.insert({ suffix, writer });
}
}
INotationWriterPtr NotationWritersRegister::writer(const std::string& suffix) const
{
auto it = m_writers.find(suffix);
if (it != m_writers.end()) {
return it->second;
}
return nullptr;
}

View file

@ -0,0 +1,37 @@
//=============================================================================
// MuseScore
// Music Composition & Notation
//
// Copyright (C) 2020 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 2.
//
// 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, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//=============================================================================
#ifndef MU_NOTATION_NOTATIONWRITERSREGISTER_H
#define MU_NOTATION_NOTATIONWRITERSREGISTER_H
#include "../inotationwritersregister.h"
namespace mu::notation {
class NotationWritersRegister : public INotationWritersRegister
{
public:
void reg(const std::vector<std::string>& suffixes, INotationWriterPtr writer) override;
INotationWriterPtr writer(const std::string& suffix) const override;
private:
std::map<std::string, INotationWriterPtr> m_writers;
};
}
#endif // MU_NOTATION_NOTATIONWRITERSREGISTER_H