Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
jcelerier committed Aug 28, 2015
2 parents d7f967a + eee319a commit 265c73b
Show file tree
Hide file tree
Showing 415 changed files with 2,068 additions and 1,933 deletions.
15 changes: 8 additions & 7 deletions base/lib/core/application/CommandBackupFile.cpp
Original file line number Diff line number Diff line change
@@ -1,30 +1,31 @@
#include "CommandBackupFile.hpp"
#include <iscore/serialization/DataStreamVisitor.hpp>
#include <core/command/CommandStack.hpp>
using namespace iscore;
#include <iscore/tools/Todo.hpp>

using namespace iscore;
CommandBackupFile::CommandBackupFile(const iscore::CommandStack &stack, QObject *parent):
QObject{parent},
m_stack{stack}
{
m_file.open();

// Set-up signals
connect(&m_stack, &CommandStack::sig_push,
con(m_stack, &CommandStack::sig_push,
this, &CommandBackupFile::on_push);
connect(&m_stack, &CommandStack::sig_undo,
con(m_stack, &CommandStack::sig_undo,
this, &CommandBackupFile::on_undo);
connect(&m_stack, &CommandStack::sig_redo,
con(m_stack, &CommandStack::sig_redo,
this, &CommandBackupFile::on_redo);
connect(&m_stack, &CommandStack::sig_indexChanged,
con(m_stack, &CommandStack::sig_indexChanged,
this, &CommandBackupFile::on_indexChanged);

// Load initial state
for(auto&& cmd : m_stack.m_undoable)
for(const auto& cmd : m_stack.m_undoable)
{
m_savedUndo.push({{cmd->parentName(), cmd->name()}, cmd->serialize()});
}
for(auto&& cmd : m_stack.m_redoable)
for(const auto& cmd : m_stack.m_redoable)
{
m_savedRedo.push({{cmd->parentName(), cmd->name()}, cmd->serialize()});
}
Expand Down
2 changes: 1 addition & 1 deletion base/lib/core/document/Document.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ Document::Document(DocumentDelegateFactoryInterface* factory,

void Document::init()
{
connect(&m_selectionStack, &SelectionStack::currentSelectionChanged,
con(m_selectionStack, &SelectionStack::currentSelectionChanged,
this, [&] (const Selection& s)
{
for(auto& panel : m_model->panels())
Expand Down
2 changes: 1 addition & 1 deletion base/lib/core/document/DocumentModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ using namespace iscore;

DocumentModel::DocumentModel(DocumentDelegateFactoryInterface* fact,
QObject* parent) :
IdentifiedObject {id_type<DocumentModel>(getNextId()), "DocumentModel", parent},
IdentifiedObject {Id<DocumentModel>(getNextId()), "DocumentModel", parent},
m_model{fact->makeModel(this)}
{
}
Expand Down
6 changes: 3 additions & 3 deletions base/lib/core/document/DocumentSerialization.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ void DocumentModel::loadDocumentAsByteArray(
}

// Load the document model
id_type<DocumentModel> docid;
Id<DocumentModel> docid;

DataStream::Deserializer doc_writer{doc};
doc_writer.writeTo(docid);
Expand All @@ -175,7 +175,7 @@ void DocumentModel::loadDocumentAsJson(
const QJsonObject& json,
DocumentDelegateFactoryInterface* fact)
{
this->setId(fromJsonValue<id_type<DocumentModel>>(json["DocumentId"]));
this->setId(fromJsonValue<Id<DocumentModel>>(json["DocumentId"]));

// Load the plug-in models
auto plugin_control = iscore::IPresenter::pluginControls();
Expand All @@ -201,7 +201,7 @@ void DocumentModel::loadDocumentAsJson(
DocumentModel::DocumentModel(const QVariant& data,
DocumentDelegateFactoryInterface* fact,
QObject* parent) :
IdentifiedObject {id_type<DocumentModel>(getNextId()), "DocumentModel", parent}
IdentifiedObject {Id<DocumentModel>(getNextId()), "DocumentModel", parent}
{
using namespace std;
if(data.canConvert(QMetaType::QByteArray))
Expand Down
22 changes: 0 additions & 22 deletions base/lib/iscore/Settings.hpp
Original file line number Diff line number Diff line change
@@ -1,22 +0,0 @@
#pragma once
#include "iscore_compiler_detection.hpp"
#include <iscore/tools/Todo.hpp>

#if ISCORE_COMPILER_CXX_RELAXED_CONSTEXPR
#define ISCORE_RELAXED_CONSTEXPR constexpr
#else
#define ISCORE_RELAXED_CONSTEXPR
#endif


#ifdef ISCORE_DEBUG
template<typename T, typename U>
T checked_cast(U&& other)
{
auto res = dynamic_cast<T>(other);
ISCORE_ASSERT(res);
return res;
}
#else
#define checked_cast static_cast
#endif
9 changes: 5 additions & 4 deletions base/lib/iscore/command/PropertyCommand.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ namespace iscore
{
public:
using SerializableCommand::SerializableCommand;
template<typename... Args>
PropertyCommand(ObjectPath&& path,
template<typename Path_T, typename... Args>
PropertyCommand(Path_T&& path,
const QString& property,
const QVariant& newval,
Args&&... args):
SerializableCommand{std::forward<Args>(args)...},
m_path{std::move(path)},
m_path{std::move(std::move(path).moveUnsafePath())},
m_property{property},
m_new{newval}
{
Expand All @@ -25,7 +25,8 @@ namespace iscore
void undo() override;
void redo() override;

void update(const ObjectPath&, const QVariant& newval)
template<typename Path_T>
void update(const Path_T&, const QVariant& newval)
{
m_new = newval;
}
Expand Down
3 changes: 2 additions & 1 deletion base/lib/iscore/document/DocumentInterface.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,9 @@ namespace iscore
ObjectPath unsafe_path(const QObject& obj);

template<typename T>
ModelPath<T> safe_path(const T& obj)
Path<T> path(const T& obj)
{
static_assert(!std::is_pointer<T>::value, "Don't pass a pointer to path");
return unsafe_path(static_cast<const QObject&>(obj));
}

Expand Down
2 changes: 1 addition & 1 deletion base/lib/iscore/locking/ObjectLocker.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ namespace iscore
class LockHelper
{
public:
LockHelper(QObject* model, ObjectLocker& locker):
LockHelper(QObject& model, ObjectLocker& locker):
m_path{IDocument::unsafe_path(model)},
m_locker{locker}
{
Expand Down
6 changes: 3 additions & 3 deletions base/lib/iscore/serialization/DataStreamVisitor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class Visitor<Reader<DataStream>> : public AbstractVisitor
}

template<typename T>
void readFrom(const id_type<T>& obj)
void readFrom(const Id<T>& obj)
{
m_stream << bool (obj.val());

Expand Down Expand Up @@ -124,7 +124,7 @@ class Visitor<Writer<DataStream>> : public AbstractVisitor
}

template<typename T>
void writeTo(id_type<T>& obj)
void writeTo(Id<T>& obj)
{
bool init {};
int32_t val {};
Expand All @@ -144,7 +144,7 @@ class Visitor<Writer<DataStream>> : public AbstractVisitor
template<typename T>
void writeTo(IdentifiedObject<T>& obj)
{
id_type<T> id;
Id<T> id;
writeTo(id);
obj.setId(std::move(id));
}
Expand Down
10 changes: 5 additions & 5 deletions base/lib/iscore/serialization/JSONValueVisitor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class Visitor<Reader<JSONValue>> : public AbstractVisitor
void readFrom(const T&);

template<typename T>
void readFrom(const id_type<T>& obj)
void readFrom(const Id<T>& obj)
{
readFrom(obj.val());
}
Expand Down Expand Up @@ -70,9 +70,9 @@ class Visitor<Writer<JSONValue>> : public AbstractVisitor
void writeTo(T&);

template<typename T>
void writeTo(id_type<T>& obj)
void writeTo(Id<T>& obj)
{
typename id_type<T>::value_type id_impl;
typename Id<T>::value_type id_impl;
writeTo(id_impl);
obj.setVal(std::move(id_impl));
}
Expand Down Expand Up @@ -147,10 +147,10 @@ T fromJsonValue(const QJsonValueRef& json)
}

template<template<typename U> class T, typename V>
void fromJsonValueArray(const QJsonArray&& json_arr, T<id_type<V>>& arr)
void fromJsonValueArray(const QJsonArray&& json_arr, T<Id<V>>& arr)
{
for(const auto& elt : json_arr)
{
arr.push_back(fromJsonValue<id_type<V>>(elt));
arr.push_back(fromJsonValue<Id<V>>(elt));
}
}
6 changes: 3 additions & 3 deletions base/lib/iscore/serialization/JSONVisitor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,9 @@ class Visitor<Writer<JSONObject>> : public AbstractVisitor
template<typename T>
void writeTo(IdentifiedObject<T>& obj)
{
typename id_type<T>::value_type id_impl;
typename Id<T>::value_type id_impl;
writeTo(id_impl);
id_type<T> id;
Id<T> id;
id.setVal(std::move(id_impl));
obj.setId(std::move(id));
}
Expand Down Expand Up @@ -202,7 +202,7 @@ QJsonArray toJsonArray(const Container& array)
}

template<template<typename U> class T, typename V>
QJsonArray toJsonArray(const T<id_type<V>>& array)
QJsonArray toJsonArray(const T<Id<V>>& array)
{
QJsonArray arr;

Expand Down
8 changes: 4 additions & 4 deletions base/lib/iscore/statemachine/StateMachineUtils.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#pragma once
#include <iscore/tools/ObjectPath.hpp>
#include <iscore/tools/ModelPath.hpp>

#include <QState>
#include <QEvent>
Expand All @@ -16,19 +16,19 @@ struct NumberedEvent : public QEvent
template<typename Element, int N>
struct NumberedWithPath_Event : public NumberedEvent<N>
{
explicit NumberedWithPath_Event(const ObjectPath& p):
explicit NumberedWithPath_Event(const Path<Element>& p):
NumberedEvent<N>{},
path{p}
{
}

explicit NumberedWithPath_Event(ObjectPath&& p):
explicit NumberedWithPath_Event(Path<Element>&& p):
NumberedEvent<N>{},
path{std::move(p)}
{
}

ObjectPath path;
Path<Element> path;
};

template<typename PointType>
Expand Down
14 changes: 7 additions & 7 deletions base/lib/iscore/tools/IdentifiedObject.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class IdentifiedObject : public IdentifiedObjectAbstract
public:
using model_type = model;
template<typename... Args>
IdentifiedObject(const id_type<model>& id,
IdentifiedObject(const Id<model>& id,
Args&& ... args) :
IdentifiedObjectAbstract {std::forward<Args> (args)...},
m_id {id}
Expand All @@ -25,7 +25,7 @@ class IdentifiedObject : public IdentifiedObjectAbstract
v.writeTo(*this);
}

const id_type<model>& id() const
const Id<model>& id() const
{
return m_id;
}
Expand All @@ -35,32 +35,32 @@ class IdentifiedObject : public IdentifiedObjectAbstract
return *m_id.val();
}

void setId(id_type<model>&& id)
void setId(Id<model>&& id)
{
m_id = id;
}

private:
id_type<model> m_id {};
Id<model> m_id {};
};


template<typename model>
std::size_t hash_value(const id_type<model>& id)
std::size_t hash_value(const Id<model>& id)
{
ISCORE_ASSERT(bool(id));

return *id.val();
}

template<typename T, typename U>
bool operator==(const T* obj, const id_type<U>& id)
bool operator==(const T* obj, const Id<U>& id)
{
return obj->id() == id;
}

template<typename T, typename U,std::enable_if_t<! std::is_pointer<std::decay_t<T>>::value>* = nullptr>
bool operator==(const T& obj, const id_type<U>& id)
bool operator==(const T& obj, const Id<U>& id)
{
return obj.id() == id;
}
12 changes: 6 additions & 6 deletions base/lib/iscore/tools/IdentifiedObjectMap.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,20 +41,20 @@ class MapBase
{ map.erase(t); }

// TODO create one that passes an iterator.
void remove(const id_type<model_type>& id)
void remove(const Id<model_type>& id)
{ map.erase(id); }

void clear()
{ map.clear(); }

auto find(const id_type<model_type>& id) const
auto find(const Id<model_type>& id) const
{ return boost::make_indirect_iterator(map.find(id)); }

auto& get() { return map.template get<0>(); }
const auto& get() const { return map.template get<0>(); }

#ifdef ISCORE_DEBUG
auto& at(const id_type<model_type>& id) const
auto& at(const Id<model_type>& id) const
{
auto item = map.find(id);
if(item == map.end())
Expand All @@ -66,7 +66,7 @@ class MapBase
return **item;
}
#else
auto& at(const id_type<model_type>& id) const
auto& at(const Id<model_type>& id) const
{ return *find(id); }
#endif

Expand Down Expand Up @@ -94,7 +94,7 @@ class IdContainer<Element, Model,
bmi::hashed_unique<
bmi::const_mem_fun<
IdentifiedObject<Model>,
const id_type<Model>&,
const Id<Model>&,
&IdentifiedObject<Model>::id
>
>
Expand Down Expand Up @@ -124,7 +124,7 @@ class IdContainer<Element, Model,
bmi::hashed_unique<
bmi::const_mem_fun<
Element,
const id_type<Model>&,
const Id<Model>&,
&Element::id
>
>
Expand Down
Loading

0 comments on commit 265c73b

Please sign in to comment.