Trying to make all C++ of the platforms happy.

This commit is contained in:
bubnikv 2019-07-04 22:52:33 +02:00
parent 9fd0c55eb8
commit 211d1ee1e3
3 changed files with 18 additions and 16 deletions

View file

@ -75,7 +75,7 @@ if (NOT MSVC)
set_target_properties(PrusaSlicer PROPERTIES OUTPUT_NAME "prusa-slicer") set_target_properties(PrusaSlicer PROPERTIES OUTPUT_NAME "prusa-slicer")
endif () endif ()
target_link_libraries(PrusaSlicer libslic3r) target_link_libraries(PrusaSlicer libslic3r cereal)
if (APPLE) if (APPLE)
# add_compile_options(-stdlib=libc++) # add_compile_options(-stdlib=libc++)
# add_definitions(-DBOOST_THREAD_DONT_USE_CHRONO -DBOOST_NO_CXX11_RVALUE_REFERENCES -DBOOST_THREAD_USES_MOVE) # add_definitions(-DBOOST_THREAD_DONT_USE_CHRONO -DBOOST_NO_CXX11_RVALUE_REFERENCES -DBOOST_THREAD_USES_MOVE)

View file

@ -69,7 +69,6 @@ protected:
void assign_new_unique_ids_recursive() { this->set_new_unique_id(); } void assign_new_unique_ids_recursive() { this->set_new_unique_id(); }
private: private:
friend class UndoRedo::StackImpl;
ObjectID m_id; ObjectID m_id;
static inline ObjectID generate_new_id() { return ObjectID(++ s_last_id); } static inline ObjectID generate_new_id() { return ObjectID(++ s_last_id); }
@ -77,9 +76,9 @@ private:
friend ObjectID wipe_tower_object_id(); friend ObjectID wipe_tower_object_id();
friend ObjectID wipe_tower_instance_id(); friend ObjectID wipe_tower_instance_id();
friend class Slic3r::UndoRedo::StackImpl;
friend class cereal::access; friend class cereal::access;
friend class Slic3r::UndoRedo::StackImpl;
template<class Archive> void serialize(Archive &ar) { ar(m_id); } template<class Archive> void serialize(Archive &ar) { ar(m_id); }
ObjectBase(const ObjectID id) : m_id(id) {} ObjectBase(const ObjectID id) : m_id(id) {}
template<class Archive> static void load_and_construct(Archive & ar, cereal::construct<ObjectBase> &construct) { ObjectID id; ar(id); construct(id); } template<class Archive> static void load_and_construct(Archive & ar, cereal::construct<ObjectBase> &construct) { ObjectID id; ar(id); construct(id); }

View file

@ -153,19 +153,7 @@ public:
bool is_serialized() const { return m_shared_object.get() == nullptr; } bool is_serialized() const { return m_shared_object.get() == nullptr; }
const std::string& serialized_data() const { return m_serialized; } const std::string& serialized_data() const { return m_serialized; }
std::shared_ptr<const T>& shared_ptr(StackImpl &stack) { std::shared_ptr<const T>& shared_ptr(StackImpl &stack);
if (m_shared_object.get() == nullptr && ! this->m_serialized.empty()) {
// Deserialize the object.
std::istringstream iss(m_serialized);
{
Slic3r::UndoRedo::InputArchive archive(stack, iss);
std::unique_ptr<std::remove_const<T>::type> mesh(new std::remove_const<T>::type());
archive(*mesh.get());
m_shared_object = std::move(mesh);
}
}
return m_shared_object;
}
#ifdef SLIC3R_UNDOREDO_DEBUG #ifdef SLIC3R_UNDOREDO_DEBUG
std::string format() override { std::string format() override {
@ -560,6 +548,21 @@ namespace cereal
namespace Slic3r { namespace Slic3r {
namespace UndoRedo { namespace UndoRedo {
template<typename T> std::shared_ptr<const T>& ImmutableObjectHistory<T>::shared_ptr(StackImpl &stack)
{
if (m_shared_object.get() == nullptr && ! this->m_serialized.empty()) {
// Deserialize the object.
std::istringstream iss(m_serialized);
{
Slic3r::UndoRedo::InputArchive archive(stack, iss);
std::unique_ptr<std::remove_const<T>::type> mesh(new std::remove_const<T>::type());
archive(*mesh.get());
m_shared_object = std::move(mesh);
}
}
return m_shared_object;
}
template<typename T, typename T_AS> ObjectID StackImpl::save_mutable_object(const T &object) template<typename T, typename T_AS> ObjectID StackImpl::save_mutable_object(const T &object)
{ {
// First find or allocate a history stack for the ObjectID of this object instance. // First find or allocate a history stack for the ObjectID of this object instance.