summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--slicer/slicer/common.ice4
-rw-r--r--slicer/slicer/modelParts.h3
-rw-r--r--slicer/slicer/modelPartsTypes.cpp6
-rw-r--r--slicer/slicer/modelPartsTypes.impl.h68
4 files changed, 32 insertions, 49 deletions
diff --git a/slicer/slicer/common.ice b/slicer/slicer/common.ice
index ad3ff1f..c082102 100644
--- a/slicer/slicer/common.ice
+++ b/slicer/slicer/common.ice
@@ -19,7 +19,9 @@ module Slicer {
["cpp:ice_print"]
exception UnsupportedModelType extends RuntimeError { };
["cpp:ice_print"]
- exception LocalTypeException extends RuntimeError { };
+ exception LocalTypeException extends RuntimeError {
+ string type;
+ };
["cpp:ice_print"]
exception NoConversionFound extends RuntimeError {
string type;
diff --git a/slicer/slicer/modelParts.h b/slicer/slicer/modelParts.h
index 65be827..c9be22e 100644
--- a/slicer/slicer/modelParts.h
+++ b/slicer/slicer/modelParts.h
@@ -185,5 +185,8 @@ namespace Slicer {
void OnContained(const ModelPartHandler &) override;
ModelPartParam mp;
+
+ protected:
+ [[noreturn]] static void throwLocalTypeException(const std::type_info &);
};
}
diff --git a/slicer/slicer/modelPartsTypes.cpp b/slicer/slicer/modelPartsTypes.cpp
index 0e3f78a..c2c8e79 100644
--- a/slicer/slicer/modelPartsTypes.cpp
+++ b/slicer/slicer/modelPartsTypes.cpp
@@ -157,6 +157,12 @@ namespace Slicer {
return mp->OnContained(h);
}
+ void
+ ModelPartForRootBase::throwLocalTypeException(const std::type_info & type)
+ {
+ throw LocalTypeException(ModelPartForComplexBase::demangle(type.name()));
+ }
+
bool
ModelPartForSimpleBase::HasValue() const
{
diff --git a/slicer/slicer/modelPartsTypes.impl.h b/slicer/slicer/modelPartsTypes.impl.h
index b1f0df8..9c141f7 100644
--- a/slicer/slicer/modelPartsTypes.impl.h
+++ b/slicer/slicer/modelPartsTypes.impl.h
@@ -133,70 +133,42 @@ namespace Slicer {
template<typename T>
void
- typeWrite(::Ice::OutputStream & s, const ::Ice::optional<T> & m)
- {
- if constexpr (!isLocal<T>::value) {
- s.startEncapsulation();
- s.write(0, m);
- s.endEncapsulation();
- }
- else {
- throw LocalTypeException();
- }
- }
-
- template<typename T>
- void
- typeWrite(::Ice::OutputStream & s, const T & m)
- {
- if constexpr (!isLocal<T>::value) {
- s.write(m);
- }
- else {
- throw LocalTypeException();
- }
- }
-
- template<typename T>
- void
- typeRead(::Ice::InputStream & s, ::Ice::optional<T> & m)
+ ModelPartForRoot<T>::Write(::Ice::OutputStream & s) const
{
if constexpr (!isLocal<T>::value) {
- s.startEncapsulation();
- s.read(0, m);
- s.endEncapsulation();
+ if constexpr (isOptional<T>::value) {
+ s.startEncapsulation();
+ s.write(0, *ModelObject);
+ s.endEncapsulation();
+ }
+ else {
+ s.write(*ModelObject);
+ }
}
else {
- throw LocalTypeException();
+ ModelPartForRootBase::throwLocalTypeException(typeid(T));
}
}
template<typename T>
void
- typeRead(::Ice::InputStream & s, T & m)
+ ModelPartForRoot<T>::Read(::Ice::InputStream & s)
{
if constexpr (!isLocal<T>::value) {
- s.read(m);
+ if constexpr (isOptional<T>::value) {
+ s.startEncapsulation();
+ s.read(0, *ModelObject);
+ s.endEncapsulation();
+ }
+ else {
+ s.read(*ModelObject);
+ }
}
else {
- throw LocalTypeException();
+ ModelPartForRootBase::throwLocalTypeException(typeid(T));
}
}
- template<typename T>
- void
- ModelPartForRoot<T>::Write(::Ice::OutputStream & s) const
- {
- typeWrite(s, *ModelObject);
- }
-
- template<typename T>
- void
- ModelPartForRoot<T>::Read(::Ice::InputStream & s)
- {
- typeRead(s, *ModelObject);
- }
-
// ModelPartForSimple
template<typename T>
void