Skip to content

Commit

Permalink
tweak
Browse files Browse the repository at this point in the history
  • Loading branch information
JossWhittle committed Sep 30, 2016
1 parent cc87c0b commit 911334c
Showing 1 changed file with 34 additions and 4 deletions.
38 changes: 34 additions & 4 deletions MEL_deepcopy.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -304,9 +304,9 @@ namespace MEL {
template<typename T, typename R = void>
using enable_if_stl = typename std::enable_if<is_vector<T>::value || is_list<T>::value, R>::type; // || is_string<T>::value
template<typename T, typename R = void>
using enable_if_not_pointer_not_stl = typename std::enable_if<(!is_vector<T>::value || is_list<T>::value) && !std::is_pointer<T>::value, R>::type; // || is_string<T>::value
using enable_if_not_pointer_not_stl = typename std::enable_if<!(is_vector<T>::value || is_list<T>::value) && !std::is_pointer<T>::value, R>::type; // || is_string<T>::value
template<typename T, typename R = void>
using enable_if_deep_not_pointer_not_stl = typename std::enable_if<HasDeepCopyMethod<T>::Has && (!is_vector<T>::value || is_list<T>::value) && !std::is_pointer<T>::value, R>::type; // || is_string<T>::value
using enable_if_deep_not_pointer_not_stl = typename std::enable_if<HasDeepCopyMethod<T>::Has && !(is_vector<T>::value || is_list<T>::value) && !std::is_pointer<T>::value, R>::type; // || is_string<T>::value

template<typename T, typename TRANSPORT_METHOD, typename HASH_MAP>
using DEEP_FUNCTOR = void(*)(T&, MEL::Deep::Message<TRANSPORT_METHOD, HASH_MAP>&);
Expand Down Expand Up @@ -531,6 +531,21 @@ namespace MEL {
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// STL

inline void packSTL(std::string &obj) {
int len;
if (TRANSPORT_METHOD::SOURCE) {
len = obj.size();
transport(len);
}
else {
transport(len);
new (&obj) std::string(len, ' ');
}

char *p = &obj[0];
if (len > 0) transport(p, len);
};

template<typename T>
inline enable_if_not_deep<T> packSTL(std::vector<T> &obj) {
int len = obj.size();
Expand Down Expand Up @@ -747,11 +762,16 @@ namespace MEL {
return *this;
};

template<typename T>
template<typename T>
inline Message<TRANSPORT_METHOD, HASH_MAP>& operator&(T &obj) {
packVar(obj);
return *this;
};

inline Message<TRANSPORT_METHOD, HASH_MAP>& operator&(std::string &obj) {
packSTL(obj);
return *this;
};
};

#define TEMPLATE_STL template<typename S, typename HASH_MAP = MEL::Deep::PointerHashMap>
Expand Down Expand Up @@ -906,9 +926,14 @@ namespace MEL {
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Pointer

TEMPLATE_P
inline enable_if_pointer<P> Send(const P &ptr, const int dst, const int tag, const Comm &comm) {
Send((P) ptr, dst, tag, comm);
};

TEMPLATE_P
inline enable_if_pointer<P> Send(P &ptr, const int dst, const int tag, const Comm &comm) {
Message<TransportSend, HASH_MAP> msg(dst, tag, comm);
Message<TransportSend, HASH_MAP> msg(dst, tag, comm);
msg.packRootPtr(ptr);
};

Expand Down Expand Up @@ -2250,6 +2275,11 @@ namespace MEL {
MEL::Deep::BufferedFileWrite(ptr, file, MEL::Deep::BufferSize(ptr));
};

TEMPLATE_P
inline enable_if_pointer<P> BufferedFileWrite_FUCK(P &ptr, std::ofstream &file) {
MEL::Deep::BufferedFileWrite(ptr, file, MEL::Deep::BufferSize(ptr));
};

TEMPLATE_P_F(TransportBufferWrite)
inline enable_if_pointer<P> BufferedFileWrite(P &ptr, std::ofstream &file) {
MEL::Deep::BufferedFileWrite<P, HASH_MAP, F>(ptr, file, MEL::Deep::BufferSize<P, HASH_MAP, F>(ptr));
Expand Down

0 comments on commit 911334c

Please sign in to comment.