00001
00002
#ifndef CopiesMap_INC
00003
#define CopiesMap_INC
00004
00005
#include <map>
00006
#include <string>
00007
#include "plerror.h"
00008
00014 #define NODEEPCOPY(TYPE) \
00015
inline void deepCopyField(TYPE&, CopiesMap&) {} \
00016
inline void deepCopyField(Array<TYPE>&, CopiesMap&) {}
00017
00018
namespace PLearn {
00019
00020
class VMField;
00021
class VMFieldStat;
00022
template <
class T>
class Array;
00023
00024
using namespace std;
00025
00028 typedef map<const void*,void*>
CopiesMap;
00029
00031 typedef map<string, float>
map_string_float;
00032 typedef map<string, double>
map_string_double;
00033 typedef map<double, string>
map_double_string;
00034 typedef map<float, string>
map_float_string;
00035
00046
00047
NODEEPCOPY(
double)
00048 NODEEPCOPY(
float)
00049 NODEEPCOPY(
int)
00050 NODEEPCOPY(
bool)
00051 NODEEPCOPY(map_string_float)
00052 NODEEPCOPY(map_string_double)
00053 NODEEPCOPY(map_float_string)
00054 NODEEPCOPY(map_double_string)
00055 NODEEPCOPY(
string)
00056 NODEEPCOPY(
VMField)
00057 NODEEPCOPY(
VMFieldStat)
00058
00060 template <class T>
00061 inline
void deepCopyField(T&, CopiesMap&)
00062 {
00064
PLWARNING(
00065
"In CopiesMap.h - deepCopyField not handled for this type. "
00066
"If it actually doesn't need deep copy, edit CopiesMap.h and add NODEEPCOPY(your_type) to remove this warning."
00067 );
00068 }
00069
00070
template <
class T>
00071 inline void deepCopyField(T*& field, CopiesMap& copies)
00072 {
00073
if (field)
00074 field = field->deepCopy(copies);
00075 }
00076
00078
template<
class T>
00079 T*
deepCopy(
const T* source, CopiesMap& copies)
00080 {
return source->deepCopy(copies); }
00081
00083
template<
class T>
00084 inline T*
deepCopy(
const T* source)
00085 {
00086
CopiesMap copies;
00087
return deepCopy(source, copies);
00088 }
00089
00090
00091 }
00092
00093
#endif //ndef CopiesMap_INC