|
@@ -51,19 +51,12 @@ namespace igl
|
|
|
|
|
|
template <typename T>
|
|
|
IGL_INLINE bool serialize(const T& obj,const std::string& objectName,std::vector<char>& buffer)
|
|
|
- {
|
|
|
- std::map<std::uintptr_t,IndexedPointerBase*> handler;
|
|
|
- return serialize(obj,objectName,buffer,0,handler);
|
|
|
- }
|
|
|
-
|
|
|
- template <typename T>
|
|
|
- IGL_INLINE bool serialize(const T& obj,const std::string& objectName,std::vector<char>& buffer,size_t offset,std::map<std::uintptr_t,IndexedPointerBase*>& memoryMap)
|
|
|
{
|
|
|
// serialize object data
|
|
|
size_t size = serialization::getByteSize(obj);
|
|
|
std::vector<char> tmp(size);
|
|
|
auto it = tmp.begin();
|
|
|
- serialization::serialize(obj,tmp,it,memoryMap);
|
|
|
+ serialization::serialize(obj,tmp,it);
|
|
|
|
|
|
std::string objectType(typeid(obj).name());
|
|
|
size_t newObjectSize = tmp.size();
|
|
@@ -76,9 +69,9 @@ namespace igl
|
|
|
std::vector<char>::iterator iter = buffer.begin()+curSize;
|
|
|
|
|
|
// serialize object header (name/type/size)
|
|
|
- serialization::serialize(objectName,buffer,iter,memoryMap);
|
|
|
- serialization::serialize(objectType,buffer,iter,memoryMap);
|
|
|
- serialization::serialize(newObjectSize,buffer,iter,memoryMap);
|
|
|
+ serialization::serialize(objectName,buffer,iter);
|
|
|
+ serialization::serialize(objectType,buffer,iter);
|
|
|
+ serialization::serialize(newObjectSize,buffer,iter);
|
|
|
|
|
|
// copy serialized data to buffer
|
|
|
iter = std::copy(tmp.begin(),tmp.end(),iter);
|
|
@@ -288,7 +281,7 @@ namespace igl
|
|
|
}
|
|
|
|
|
|
template <typename T>
|
|
|
- IGL_INLINE typename std::enable_if<!is_serializable<T>::value>::type serialize(const T& obj,std::vector<char>& buffer,std::vector<char>::iterator& iter,std::map<std::uintptr_t,IndexedPointerBase*>& memoryMap)
|
|
|
+ IGL_INLINE typename std::enable_if<!is_serializable<T>::value>::type serialize(const T& obj,std::vector<char>& buffer,std::vector<char>::iterator& iter)
|
|
|
{
|
|
|
// data
|
|
|
std::vector<char> tmp;
|
|
@@ -296,7 +289,7 @@ namespace igl
|
|
|
|
|
|
// size
|
|
|
size_t size = buffer.size();
|
|
|
- serialization::serialize(tmp.size(),buffer,iter,memoryMap);
|
|
|
+ serialization::serialize(tmp.size(),buffer,iter);
|
|
|
size_t cur = iter - buffer.begin();
|
|
|
|
|
|
buffer.resize(size+tmp.size());
|
|
@@ -327,9 +320,9 @@ namespace igl
|
|
|
}
|
|
|
|
|
|
template <typename T>
|
|
|
- IGL_INLINE typename std::enable_if<std::is_fundamental<T>::value>::type serialize(const T& obj,std::vector<char>& buffer,std::vector<char>::iterator& iter,std::map<std::uintptr_t,IndexedPointerBase*>& memoryMap)
|
|
|
+ IGL_INLINE typename std::enable_if<std::is_fundamental<T>::value>::type serialize(const T& obj,std::vector<char>& buffer,std::vector<char>::iterator& iter)
|
|
|
{
|
|
|
- //serialization::updateMemoryMap(obj,sizeof(T),memoryMap);
|
|
|
+ //serialization::updateMemoryMap(obj,sizeof(T));
|
|
|
const uint8_t* ptr = reinterpret_cast<const uint8_t*>(&obj);
|
|
|
iter = std::copy(ptr,ptr+sizeof(T),iter);
|
|
|
}
|
|
@@ -349,12 +342,12 @@ namespace igl
|
|
|
return getByteSize(obj.length())+obj.length()*sizeof(uint8_t);
|
|
|
}
|
|
|
|
|
|
- IGL_INLINE void serialize(const std::string& obj,std::vector<char>& buffer,std::vector<char>::iterator& iter,std::map<std::uintptr_t,IndexedPointerBase*>& memoryMap)
|
|
|
+ IGL_INLINE void serialize(const std::string& obj,std::vector<char>& buffer,std::vector<char>::iterator& iter)
|
|
|
{
|
|
|
- serialization::serialize(obj.length(),buffer,iter,memoryMap);
|
|
|
+ serialization::serialize(obj.length(),buffer,iter);
|
|
|
for(const auto& cur : obj)
|
|
|
{
|
|
|
- serialization::serialize(cur,buffer,iter,memoryMap);
|
|
|
+ serialization::serialize(cur,buffer,iter);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -381,7 +374,7 @@ namespace igl
|
|
|
}
|
|
|
|
|
|
template <typename T>
|
|
|
- IGL_INLINE typename std::enable_if<std::is_base_of<SerializableBase,T>::value>::type serialize(const T& obj,std::vector<char>& buffer,std::vector<char>::iterator& iter,std::map<std::uintptr_t,IndexedPointerBase*>& memoryMap)
|
|
|
+ IGL_INLINE typename std::enable_if<std::is_base_of<SerializableBase,T>::value>::type serialize(const T& obj,std::vector<char>& buffer,std::vector<char>::iterator& iter)
|
|
|
{
|
|
|
// data
|
|
|
std::vector<char> tmp;
|
|
@@ -389,7 +382,7 @@ namespace igl
|
|
|
|
|
|
// size
|
|
|
size_t size = buffer.size();
|
|
|
- serialization::serialize(tmp.size(),buffer,iter,memoryMap);
|
|
|
+ serialization::serialize(tmp.size(),buffer,iter);
|
|
|
size_t cur = iter - buffer.begin();
|
|
|
|
|
|
buffer.resize(size+tmp.size());
|
|
@@ -422,10 +415,10 @@ namespace igl
|
|
|
}
|
|
|
|
|
|
template <typename T1,typename T2>
|
|
|
- IGL_INLINE void serialize(const std::pair<T1,T2>& obj,std::vector<char>& buffer,std::vector<char>::iterator& iter,std::map<std::uintptr_t,IndexedPointerBase*>& memoryMap)
|
|
|
+ IGL_INLINE void serialize(const std::pair<T1,T2>& obj,std::vector<char>& buffer,std::vector<char>::iterator& iter)
|
|
|
{
|
|
|
- serialization::serialize(obj.first,buffer,iter,memoryMap);
|
|
|
- serialization::serialize(obj.second,buffer,iter,memoryMap);
|
|
|
+ serialization::serialize(obj.first,buffer,iter);
|
|
|
+ serialization::serialize(obj.second,buffer,iter);
|
|
|
}
|
|
|
|
|
|
template <typename T1,typename T2>
|
|
@@ -444,13 +437,13 @@ namespace igl
|
|
|
}
|
|
|
|
|
|
template <typename T1,typename T2>
|
|
|
- IGL_INLINE void serialize(const std::vector<T1,T2>& obj,std::vector<char>& buffer,std::vector<char>::iterator& iter,std::map<std::uintptr_t,IndexedPointerBase*>& memoryMap)
|
|
|
+ IGL_INLINE void serialize(const std::vector<T1,T2>& obj,std::vector<char>& buffer,std::vector<char>::iterator& iter)
|
|
|
{
|
|
|
size_t size = obj.size();
|
|
|
- serialization::serialize(size,buffer,iter,memoryMap);
|
|
|
- for(const auto& cur : obj)
|
|
|
+ serialization::serialize(size,buffer,iter);
|
|
|
+ for(const T1& cur : obj)
|
|
|
{
|
|
|
- serialization::serialize(cur,buffer,iter,memoryMap);
|
|
|
+ serialization::serialize(cur,buffer,iter);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -461,12 +454,27 @@ namespace igl
|
|
|
serialization::deserialize(size,iter);
|
|
|
|
|
|
obj.resize(size);
|
|
|
- for(auto& v : obj)
|
|
|
+ for(T1& v : obj)
|
|
|
{
|
|
|
serialization::deserialize(v,iter);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ template <typename T2>
|
|
|
+ IGL_INLINE void deserialize(std::vector<bool,T2>& obj,std::vector<char>::const_iterator& iter)
|
|
|
+ {
|
|
|
+ size_t size;
|
|
|
+ serialization::deserialize(size,iter);
|
|
|
+
|
|
|
+ obj.resize(size);
|
|
|
+ for(int i=0;i<obj.size();i++)
|
|
|
+ {
|
|
|
+ bool val;
|
|
|
+ serialization::deserialize(val,iter);
|
|
|
+ obj[i] = val;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
//std::set
|
|
|
|
|
|
template <typename T>
|
|
@@ -476,12 +484,12 @@ namespace igl
|
|
|
}
|
|
|
|
|
|
template <typename T>
|
|
|
- IGL_INLINE void serialize(const std::set<T>& obj,std::vector<char>& buffer,std::vector<char>::iterator& iter,std::map<std::uintptr_t,IndexedPointerBase*>& memoryMap)
|
|
|
+ IGL_INLINE void serialize(const std::set<T>& obj,std::vector<char>& buffer,std::vector<char>::iterator& iter)
|
|
|
{
|
|
|
- serialization::serialize(obj.size(),buffer,iter,memoryMap);
|
|
|
- for(const auto& cur : obj)
|
|
|
+ serialization::serialize(obj.size(),buffer,iter);
|
|
|
+ for(const T& cur : obj)
|
|
|
{
|
|
|
- serialization::serialize(cur,buffer,iter,memoryMap);
|
|
|
+ serialization::serialize(cur,buffer,iter);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -509,12 +517,12 @@ namespace igl
|
|
|
}
|
|
|
|
|
|
template <typename T1,typename T2>
|
|
|
- IGL_INLINE void serialize(const std::map<T1,T2>& obj,std::vector<char>& buffer,std::vector<char>::iterator& iter,std::map<std::uintptr_t,IndexedPointerBase*>& memoryMap)
|
|
|
+ IGL_INLINE void serialize(const std::map<T1,T2>& obj,std::vector<char>& buffer,std::vector<char>::iterator& iter)
|
|
|
{
|
|
|
- serialization::serialize(obj.size(),buffer,iter,memoryMap);
|
|
|
+ serialization::serialize(obj.size(),buffer,iter);
|
|
|
for(const auto& cur : obj)
|
|
|
{
|
|
|
- serialization::serialize(cur,buffer,iter,memoryMap);
|
|
|
+ serialization::serialize(cur,buffer,iter);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -542,10 +550,10 @@ namespace igl
|
|
|
}
|
|
|
|
|
|
template<typename T,int R,int C,int P,int MR,int MC>
|
|
|
- IGL_INLINE void serialize(const Eigen::Matrix<T,R,C,P,MR,MC>& obj,std::vector<char>& buffer,std::vector<char>::iterator& iter,std::map<std::uintptr_t,IndexedPointerBase*>& memoryMap)
|
|
|
+ IGL_INLINE void serialize(const Eigen::Matrix<T,R,C,P,MR,MC>& obj,std::vector<char>& buffer,std::vector<char>::iterator& iter)
|
|
|
{
|
|
|
- serialization::serialize(obj.rows(),buffer,iter,memoryMap);
|
|
|
- serialization::serialize(obj.cols(),buffer,iter,memoryMap);
|
|
|
+ serialization::serialize(obj.rows(),buffer,iter);
|
|
|
+ serialization::serialize(obj.cols(),buffer,iter);
|
|
|
size_t size = sizeof(T)*obj.rows()*obj.cols();
|
|
|
auto ptr = reinterpret_cast<const uint8_t*>(obj.data());
|
|
|
iter = std::copy(ptr,ptr+size,iter);
|
|
@@ -573,19 +581,19 @@ namespace igl
|
|
|
}
|
|
|
|
|
|
template<typename T,int P,typename I>
|
|
|
- IGL_INLINE void serialize(const Eigen::SparseMatrix<T,P,I>& obj,std::vector<char>& buffer,std::vector<char>::iterator& iter,std::map<std::uintptr_t,IndexedPointerBase*>& memoryMap)
|
|
|
+ IGL_INLINE void serialize(const Eigen::SparseMatrix<T,P,I>& obj,std::vector<char>& buffer,std::vector<char>::iterator& iter)
|
|
|
{
|
|
|
- serialization::serialize(obj.rows(),buffer,iter,memoryMap);
|
|
|
- serialization::serialize(obj.cols(),buffer,iter,memoryMap);
|
|
|
- serialization::serialize(obj.nonZeros(),buffer,iter,memoryMap);
|
|
|
+ serialization::serialize(obj.rows(),buffer,iter);
|
|
|
+ serialization::serialize(obj.cols(),buffer,iter);
|
|
|
+ serialization::serialize(obj.nonZeros(),buffer,iter);
|
|
|
|
|
|
for(int k=0;k<obj.outerSize();++k)
|
|
|
{
|
|
|
for(typename Eigen::SparseMatrix<T,P,I>::InnerIterator it(obj,k);it;++it)
|
|
|
{
|
|
|
- serialization::serialize(it.row(),buffer,iter,memoryMap);
|
|
|
- serialization::serialize(it.col(),buffer,iter,memoryMap);
|
|
|
- serialization::serialize(it.value(),buffer,iter,memoryMap);
|
|
|
+ serialization::serialize(it.row(),buffer,iter);
|
|
|
+ serialization::serialize(it.col(),buffer,iter);
|
|
|
+ serialization::serialize(it.value(),buffer,iter);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -628,12 +636,12 @@ namespace igl
|
|
|
}
|
|
|
|
|
|
template <typename T>
|
|
|
- IGL_INLINE typename std::enable_if<std::is_pointer<T>::value>::type serialize(const T& obj,std::vector<char>& buffer,std::vector<char>::iterator& iter,std::map<std::uintptr_t,IndexedPointerBase*>& memoryMap)
|
|
|
+ IGL_INLINE typename std::enable_if<std::is_pointer<T>::value>::type serialize(const T& obj,std::vector<char>& buffer,std::vector<char>::iterator& iter)
|
|
|
{
|
|
|
- serialization::serialize(obj == nullptr,buffer,iter,memoryMap);
|
|
|
+ serialization::serialize(obj == nullptr,buffer,iter);
|
|
|
|
|
|
if(obj)
|
|
|
- serialization::serialize(*obj,buffer,iter,memoryMap);
|
|
|
+ serialization::serialize(*obj,buffer,iter);
|
|
|
}
|
|
|
|
|
|
template <typename T>
|
|
@@ -673,9 +681,9 @@ namespace igl
|
|
|
}
|
|
|
|
|
|
template <typename T>
|
|
|
- IGL_INLINE typename std::enable_if<serialization::is_smart_ptr<T>::value>::type serialize(const T& obj,std::vector<char>& buffer,std::vector<char>::iterator& iter,std::map<std::uintptr_t,IndexedPointerBase*>& memoryMap)
|
|
|
+ IGL_INLINE typename std::enable_if<serialization::is_smart_ptr<T>::value>::type serialize(const T& obj,std::vector<char>& buffer,std::vector<char>::iterator& iter)
|
|
|
{
|
|
|
- serialize(obj.get(),buffer,iter,memoryMap);
|
|
|
+ serialize(obj.get(),buffer,iter);
|
|
|
}
|
|
|
|
|
|
template <template<typename> class T0,typename T1>
|
|
@@ -704,7 +712,7 @@ namespace igl
|
|
|
}
|
|
|
|
|
|
template <typename T>
|
|
|
- IGL_INLINE void serialize(const std::weak_ptr<T>& obj,std::vector<char>& buffer,std::vector<char>::iterator& iter,std::map<std::uintptr_t,IndexedPointerBase*>& memoryMap)
|
|
|
+ IGL_INLINE void serialize(const std::weak_ptr<T>& obj,std::vector<char>& buffer,std::vector<char>::iterator& iter)
|
|
|
{
|
|
|
|
|
|
}
|