mirror of https://github.com/KLayout/klayout.git
WIP: removing need to tl::type_traits
This commit is contained in:
parent
dfa1c0dbfd
commit
132ad2ed8d
|
|
@ -2396,6 +2396,7 @@ END
|
|||
# forward decl
|
||||
@ext_decls << "#{struct.kind.to_s} #{cls};\n\n"
|
||||
|
||||
if false # @@@ no longer needed
|
||||
# type traits included ...
|
||||
tt = "namespace tl { template <> struct type_traits<#{cls}> : public type_traits<void> {\n"
|
||||
if !conf.has_copy_ctor?(cls) || is_abstract || (eq_op && eq_op.visibility == :private)
|
||||
|
|
@ -2409,6 +2410,7 @@ END
|
|||
end
|
||||
tt += "}; }\n\n"
|
||||
@ext_decls << tt
|
||||
end
|
||||
|
||||
# only for top-level classes external declarations are produced currently
|
||||
@ext_decls << "namespace gsi { GSI_#{modn.upcase}_PUBLIC gsi::Class<#{cls}> &qtdecl_#{clsn} (); }\n\n"
|
||||
|
|
@ -2993,6 +2995,7 @@ END
|
|||
ttfile.puts("#{struct.kind.to_s} #{cls};")
|
||||
end
|
||||
|
||||
if false # @@@ no longer needed
|
||||
ttfile.puts("namespace tl {")
|
||||
ttfile.puts "template <> struct type_traits<#{cls}> : public type_traits<void> {"
|
||||
if !conf.has_copy_ctor?(cls) || is_abstract || (eq_op && eq_op.visibility == :private)
|
||||
|
|
@ -3007,9 +3010,11 @@ END
|
|||
ttfile.puts "};"
|
||||
ttfile.puts "}"
|
||||
ttfile.puts ""
|
||||
end
|
||||
|
||||
if struct.needs_adaptor(conf)
|
||||
|
||||
if false # @@@ no longer needed
|
||||
ttfile.puts("class #{clsn}_Adaptor;")
|
||||
ttfile.puts("namespace tl {")
|
||||
ttfile.puts "template <> struct type_traits<#{clsn}_Adaptor> : public type_traits<void> {"
|
||||
|
|
@ -3022,6 +3027,7 @@ END
|
|||
ttfile.puts "};"
|
||||
ttfile.puts "}"
|
||||
ttfile.puts ""
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
|
@ -3075,6 +3081,8 @@ END
|
|||
ttfile.puts("* This file has been created automatically")
|
||||
ttfile.puts("*/")
|
||||
ttfile.puts("")
|
||||
|
||||
if false # @@@ no longer required
|
||||
ttfile.puts("#ifndef _HDR_gsiDecl#{modn}TypeTraits")
|
||||
ttfile.puts("#define _HDR_gsiDecl#{modn}TypeTraits")
|
||||
ttfile.puts("")
|
||||
|
|
@ -3092,6 +3100,7 @@ END
|
|||
elsif decl_obj.is_a?(CPPNamespace)
|
||||
|
||||
cls = decl_obj.myself
|
||||
if false # no longer required
|
||||
ttfile.puts("class #{cls}_Namespace;")
|
||||
ttfile.puts("namespace tl {")
|
||||
ttfile.puts "template <> struct type_traits<#{cls}_Namespace> : public type_traits<void> {"
|
||||
|
|
@ -3100,10 +3109,12 @@ END
|
|||
ttfile.puts "};"
|
||||
ttfile.puts("}")
|
||||
ttfile.puts ""
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
ttfile.puts("")
|
||||
ttfile.puts("#endif")
|
||||
|
|
|
|||
|
|
@ -1423,19 +1423,6 @@ typedef box<db::DCoord> DBox;
|
|||
|
||||
namespace tl
|
||||
{
|
||||
/**
|
||||
* @brief The type traits for the box type
|
||||
*/
|
||||
template <class C, class R>
|
||||
struct type_traits <db::box<C, R> > : public type_traits<void>
|
||||
{
|
||||
typedef trivial_relocate_required relocate_requirements;
|
||||
typedef true_tag supports_extractor;
|
||||
typedef true_tag supports_to_string;
|
||||
typedef true_tag has_less_operator;
|
||||
typedef true_tag has_equal_operator;
|
||||
};
|
||||
|
||||
template<> DB_PUBLIC void extractor_impl (tl::Extractor &ex, db::Box &b);
|
||||
template<> DB_PUBLIC void extractor_impl (tl::Extractor &ex, db::DBox &b);
|
||||
|
||||
|
|
|
|||
|
|
@ -1143,16 +1143,5 @@ mem_stat (MemStatistics *stat, MemStatistics::purpose_t purpose, int cat, const
|
|||
|
||||
} // namespace db
|
||||
|
||||
namespace tl
|
||||
{
|
||||
/**
|
||||
* @brief Type traits
|
||||
*/
|
||||
template <> struct type_traits <db::Cell> : public type_traits<void> {
|
||||
typedef tl::false_tag has_copy_constructor;
|
||||
typedef tl::false_tag has_default_constructor;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -110,16 +110,6 @@ private:
|
|||
|
||||
}
|
||||
|
||||
namespace tl
|
||||
{
|
||||
template <>
|
||||
struct type_traits<db::ColdProxy> : public type_traits<void>
|
||||
{
|
||||
typedef tl::false_tag has_default_constructor;
|
||||
typedef tl::false_tag has_copy_constructor;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1620,17 +1620,4 @@ private:
|
|||
|
||||
}
|
||||
|
||||
namespace tl
|
||||
{
|
||||
|
||||
template <>
|
||||
struct type_traits<db::CompoundRegionOperationNode>
|
||||
: public tl::type_traits<void>
|
||||
{
|
||||
typedef false_tag has_copy_constructor;
|
||||
typedef false_tag has_default_constructor;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -865,15 +865,5 @@ void DeepLayer::commit_shapes (VarCollector &collector, std::map<db::cell_index_
|
|||
|
||||
}
|
||||
|
||||
namespace tl
|
||||
{
|
||||
|
||||
// disable copying of the deep shape store object
|
||||
template <> struct type_traits <db::DeepShapeStore> : public type_traits<void> {
|
||||
typedef tl::false_tag has_copy_constructor;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -1500,19 +1500,6 @@ public:
|
|||
|
||||
namespace tl
|
||||
{
|
||||
/**
|
||||
* @brief The type traits for the edge type
|
||||
*/
|
||||
template <class C>
|
||||
struct type_traits <db::edge<C> > : public type_traits<void>
|
||||
{
|
||||
typedef trivial_relocate_required relocate_requirements;
|
||||
typedef true_tag supports_extractor;
|
||||
typedef true_tag supports_to_string;
|
||||
typedef true_tag has_less_operator;
|
||||
typedef true_tag has_equal_operator;
|
||||
};
|
||||
|
||||
template<> DB_PUBLIC void extractor_impl (tl::Extractor &ex, db::Edge &b);
|
||||
template<> DB_PUBLIC void extractor_impl (tl::Extractor &ex, db::DEdge &b);
|
||||
|
||||
|
|
|
|||
|
|
@ -622,19 +622,6 @@ typedef edge_pair<db::DCoord> DEdgePair;
|
|||
|
||||
namespace tl
|
||||
{
|
||||
/**
|
||||
* @brief The type traits for the edge type
|
||||
*/
|
||||
template <class C>
|
||||
struct type_traits <db::edge_pair<C> > : public type_traits<void>
|
||||
{
|
||||
typedef trivial_relocate_required relocate_requirements;
|
||||
typedef true_tag supports_extractor;
|
||||
typedef true_tag supports_to_string;
|
||||
typedef true_tag has_less_operator;
|
||||
typedef true_tag has_equal_operator;
|
||||
};
|
||||
|
||||
template<> DB_PUBLIC void extractor_impl (tl::Extractor &ex, db::EdgePair &b);
|
||||
template<> DB_PUBLIC void extractor_impl (tl::Extractor &ex, db::DEdgePair &b);
|
||||
|
||||
|
|
|
|||
|
|
@ -613,21 +613,5 @@ private:
|
|||
|
||||
}
|
||||
|
||||
namespace tl
|
||||
{
|
||||
/**
|
||||
* @brief The type traits for the box type
|
||||
*/
|
||||
template <>
|
||||
struct type_traits <db::EdgePairs> : public type_traits<void>
|
||||
{
|
||||
typedef true_tag supports_extractor;
|
||||
typedef true_tag supports_to_string;
|
||||
typedef true_tag has_less_operator;
|
||||
typedef true_tag has_equal_operator;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -1210,20 +1210,4 @@ private:
|
|||
|
||||
} // namespace db
|
||||
|
||||
namespace tl
|
||||
{
|
||||
/**
|
||||
* @brief The type traits for the region type
|
||||
*/
|
||||
template <>
|
||||
struct type_traits <db::Edges> : public type_traits<void>
|
||||
{
|
||||
typedef true_tag supports_extractor;
|
||||
typedef true_tag supports_to_string;
|
||||
typedef true_tag has_less_operator;
|
||||
typedef true_tag has_equal_operator;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -532,18 +532,5 @@ private:
|
|||
|
||||
}
|
||||
|
||||
namespace tl
|
||||
{
|
||||
|
||||
template <class TS, class TI, class TR>
|
||||
struct type_traits<db::local_processor<TS, TI, TR> > : public tl::type_traits<void>
|
||||
{
|
||||
// mark "LocalProcessor" as not having a default ctor and no copy ctor
|
||||
typedef tl::false_tag has_default_constructor;
|
||||
typedef tl::false_tag has_copy_constructor;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -229,27 +229,5 @@ inline LayerProperties &operator+= (LayerProperties &props, const LayerOffset &o
|
|||
|
||||
}
|
||||
|
||||
// tl namespace support for db::LayerProperties
|
||||
namespace tl
|
||||
{
|
||||
template <>
|
||||
struct type_traits <db::LayerProperties> : public type_traits<void>
|
||||
{
|
||||
typedef true_tag supports_extractor;
|
||||
typedef true_tag supports_to_string;
|
||||
typedef true_tag has_less_operator;
|
||||
typedef true_tag has_equal_operator;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct type_traits <db::LayerOffset> : public type_traits<void>
|
||||
{
|
||||
typedef true_tag supports_extractor;
|
||||
typedef true_tag supports_to_string;
|
||||
typedef true_tag has_less_operator;
|
||||
typedef true_tag has_equal_operator;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -1002,16 +1002,4 @@ inline void mem_stat (MemStatistics *stat, MemStatistics::purpose_t purpose, int
|
|||
|
||||
}
|
||||
|
||||
namespace tl
|
||||
{
|
||||
|
||||
template<> struct type_traits<db::LayoutToNetlist> : public tl::type_traits<void>
|
||||
{
|
||||
// mark "NetlistDeviceExtractor" as not having a default ctor and no copy ctor
|
||||
typedef tl::false_tag has_copy_constructor;
|
||||
typedef tl::false_tag has_default_constructor;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -172,16 +172,4 @@ private:
|
|||
|
||||
}
|
||||
|
||||
namespace tl
|
||||
{
|
||||
|
||||
template<> struct type_traits<db::LayoutVsSchematic> : public tl::type_traits<void>
|
||||
{
|
||||
// mark "NetlistDeviceExtractor" as not having a default ctor and no copy ctor
|
||||
typedef tl::false_tag has_copy_constructor;
|
||||
typedef tl::false_tag has_default_constructor;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -231,16 +231,6 @@ private:
|
|||
|
||||
}
|
||||
|
||||
namespace tl
|
||||
{
|
||||
/**
|
||||
* @brief Type traits
|
||||
*/
|
||||
template <> struct type_traits <db::Library> : public type_traits<void> {
|
||||
typedef tl::false_tag has_copy_constructor;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -351,15 +351,5 @@ private:
|
|||
|
||||
} // namespace db
|
||||
|
||||
namespace tl
|
||||
{
|
||||
template <>
|
||||
struct type_traits <db::Manager> : public type_traits<void>
|
||||
{
|
||||
typedef tl::false_tag has_copy_constructor;
|
||||
typedef tl::true_tag has_default_constructor;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -380,22 +380,4 @@ protected:
|
|||
|
||||
}
|
||||
|
||||
namespace tl
|
||||
{
|
||||
|
||||
template<> struct type_traits<db::NetlistComparer> : public tl::type_traits<void>
|
||||
{
|
||||
// mark "NetlistDeviceExtractor" as having a default ctor and no copy ctor
|
||||
typedef tl::false_tag has_copy_constructor;
|
||||
typedef tl::false_tag has_default_constructor;
|
||||
};
|
||||
|
||||
template<> struct type_traits<db::NetlistCompareLogger> : public tl::type_traits<void>
|
||||
{
|
||||
// mark "NetlistDeviceExtractor" as having a default ctor and no copy ctor
|
||||
typedef tl::false_tag has_copy_constructor;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -312,15 +312,4 @@ private:
|
|||
|
||||
}
|
||||
|
||||
namespace tl
|
||||
{
|
||||
|
||||
template<> struct type_traits<db::NetlistCrossReference> : public tl::type_traits<void>
|
||||
{
|
||||
// mark "NetlistDeviceExtractor" as having a default ctor and no copy ctor
|
||||
typedef tl::false_tag has_copy_constructor;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -571,16 +571,4 @@ private:
|
|||
|
||||
}
|
||||
|
||||
namespace tl
|
||||
{
|
||||
|
||||
template<> struct type_traits<db::NetlistDeviceExtractor> : public tl::type_traits<void>
|
||||
{
|
||||
// mark "NetlistDeviceExtractor" as not having a default ctor and no copy ctor
|
||||
typedef tl::false_tag has_copy_constructor;
|
||||
typedef tl::false_tag has_default_constructor;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -405,63 +405,4 @@ protected:
|
|||
|
||||
}
|
||||
|
||||
namespace tl
|
||||
{
|
||||
|
||||
template<> struct type_traits<db::NetlistDeviceExtractorMOS3Transistor> : public tl::type_traits<void>
|
||||
{
|
||||
typedef tl::false_tag has_copy_constructor;
|
||||
typedef tl::false_tag has_default_constructor;
|
||||
};
|
||||
|
||||
template<> struct type_traits<db::NetlistDeviceExtractorMOS4Transistor> : public tl::type_traits<void>
|
||||
{
|
||||
typedef tl::false_tag has_copy_constructor;
|
||||
typedef tl::false_tag has_default_constructor;
|
||||
};
|
||||
|
||||
template<> struct type_traits<db::NetlistDeviceExtractorCapacitor> : public tl::type_traits<void>
|
||||
{
|
||||
typedef tl::false_tag has_copy_constructor;
|
||||
typedef tl::false_tag has_default_constructor;
|
||||
};
|
||||
|
||||
template<> struct type_traits<db::NetlistDeviceExtractorCapacitorWithBulk> : public tl::type_traits<void>
|
||||
{
|
||||
typedef tl::false_tag has_copy_constructor;
|
||||
typedef tl::false_tag has_default_constructor;
|
||||
};
|
||||
|
||||
template<> struct type_traits<db::NetlistDeviceExtractorResistor> : public tl::type_traits<void>
|
||||
{
|
||||
typedef tl::false_tag has_copy_constructor;
|
||||
typedef tl::false_tag has_default_constructor;
|
||||
};
|
||||
|
||||
template<> struct type_traits<db::NetlistDeviceExtractorResistorWithBulk> : public tl::type_traits<void>
|
||||
{
|
||||
typedef tl::false_tag has_copy_constructor;
|
||||
typedef tl::false_tag has_default_constructor;
|
||||
};
|
||||
|
||||
template<> struct type_traits<db::NetlistDeviceExtractorBJT3Transistor> : public tl::type_traits<void>
|
||||
{
|
||||
typedef tl::false_tag has_copy_constructor;
|
||||
typedef tl::false_tag has_default_constructor;
|
||||
};
|
||||
|
||||
template<> struct type_traits<db::NetlistDeviceExtractorBJT4Transistor> : public tl::type_traits<void>
|
||||
{
|
||||
typedef tl::false_tag has_copy_constructor;
|
||||
typedef tl::false_tag has_default_constructor;
|
||||
};
|
||||
|
||||
template<> struct type_traits<db::NetlistDeviceExtractorDiode> : public tl::type_traits<void>
|
||||
{
|
||||
typedef tl::false_tag has_copy_constructor;
|
||||
typedef tl::false_tag has_default_constructor;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -52,17 +52,4 @@ public:
|
|||
|
||||
}
|
||||
|
||||
namespace tl
|
||||
{
|
||||
|
||||
template <>
|
||||
struct type_traits<db::NetlistReader>
|
||||
: public tl::type_traits<void>
|
||||
{
|
||||
typedef tl::false_tag has_default_constructor;
|
||||
typedef tl::false_tag has_copy_constructor;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -237,17 +237,4 @@ private:
|
|||
|
||||
}
|
||||
|
||||
namespace tl
|
||||
{
|
||||
|
||||
template <>
|
||||
struct type_traits<db::NetlistSpiceReader>
|
||||
: public tl::type_traits<void>
|
||||
{
|
||||
typedef tl::false_tag has_default_constructor;
|
||||
typedef tl::false_tag has_copy_constructor;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -52,17 +52,4 @@ public:
|
|||
|
||||
}
|
||||
|
||||
namespace tl
|
||||
{
|
||||
|
||||
template <>
|
||||
struct type_traits<db::NetlistWriter>
|
||||
: public tl::type_traits<void>
|
||||
{
|
||||
typedef tl::false_tag has_default_constructor;
|
||||
typedef tl::false_tag has_copy_constructor;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -535,16 +535,5 @@ private:
|
|||
|
||||
}
|
||||
|
||||
namespace tl
|
||||
{
|
||||
/**
|
||||
* @brief Type traits
|
||||
*/
|
||||
template <> struct type_traits <db::PCellDeclaration> : public type_traits<void> {
|
||||
typedef tl::false_tag has_copy_constructor;
|
||||
typedef tl::false_tag has_default_constructor;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -224,7 +224,6 @@ public:
|
|||
typedef typename coord_traits::area_type area_type;
|
||||
typedef object_tag< path<C> > tag;
|
||||
typedef tl::vector<point_type> pointlist_type;
|
||||
typedef typename tl::type_traits<pointlist_type>::relocate_requirements relocate_requirements;
|
||||
typedef db::path_point_iterator<path <C>, db::unit_trans<C> > iterator;
|
||||
|
||||
/**
|
||||
|
|
@ -1132,20 +1131,6 @@ Path round_path_corners (const Path &input, int rad, int npoints);
|
|||
|
||||
namespace tl
|
||||
{
|
||||
/**
|
||||
* @brief The type traits for the path type
|
||||
*/
|
||||
template <class C>
|
||||
struct type_traits <db::path<C> > : public type_traits<void>
|
||||
{
|
||||
typedef typename db::path<C>::relocate_requirements relocate_requirements;
|
||||
typedef true_tag has_efficient_swap;
|
||||
typedef true_tag supports_extractor;
|
||||
typedef true_tag supports_to_string;
|
||||
typedef true_tag has_less_operator;
|
||||
typedef true_tag has_equal_operator;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Special extractors for the paths
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -750,16 +750,6 @@ inline bool equal (const tl::vector<point<C> > &a, const tl::vector<point<C> > &
|
|||
|
||||
namespace tl
|
||||
{
|
||||
template <class C>
|
||||
struct type_traits <db::point<C> > : public type_traits<void>
|
||||
{
|
||||
typedef trivial_relocate_required relocate_requirements;
|
||||
typedef true_tag supports_extractor;
|
||||
typedef true_tag supports_to_string;
|
||||
typedef true_tag has_less_operator;
|
||||
typedef true_tag has_equal_operator;
|
||||
};
|
||||
|
||||
template <> DB_PUBLIC void extractor_impl (tl::Extractor &ex, db::Point &p);
|
||||
template <> DB_PUBLIC void extractor_impl (tl::Extractor &ex, db::DPoint &p);
|
||||
|
||||
|
|
|
|||
|
|
@ -1045,24 +1045,6 @@ private:
|
|||
|
||||
}
|
||||
|
||||
namespace tl
|
||||
{
|
||||
/**
|
||||
* @brief The type traits for the contour type
|
||||
*/
|
||||
template <class C>
|
||||
struct type_traits <db::polygon_contour<C> > : public type_traits<void>
|
||||
{
|
||||
// the contour just uses one pointer, hence the relocation requirements are simple
|
||||
typedef typename tl::trivial_relocate_required relocate_requirements;
|
||||
typedef true_tag has_efficient_swap;
|
||||
typedef false_tag supports_extractor;
|
||||
typedef false_tag supports_to_string;
|
||||
typedef true_tag has_less_operator;
|
||||
typedef true_tag has_equal_operator;
|
||||
};
|
||||
}
|
||||
|
||||
namespace db
|
||||
{
|
||||
|
||||
|
|
@ -1437,7 +1419,6 @@ public:
|
|||
typedef typename coord_traits::area_type area_type;
|
||||
typedef polygon_contour<C> contour_type;
|
||||
typedef tl::vector<contour_type> contour_list_type;
|
||||
typedef typename tl::type_traits<contour_list_type>::relocate_requirements relocate_requirements;
|
||||
typedef db::polygon_edge_iterator< polygon<C>, db::unit_trans<C> > polygon_edge_iterator;
|
||||
typedef db::polygon_contour_iterator< contour_type, db::unit_trans<C> > polygon_contour_iterator;
|
||||
typedef db::object_tag< polygon<C> > tag;
|
||||
|
|
@ -2439,7 +2420,6 @@ public:
|
|||
typedef typename coord_traits::area_type area_type;
|
||||
typedef polygon_contour<C> contour_type;
|
||||
typedef tl::vector<contour_type> contour_list_type;
|
||||
typedef typename tl::type_traits<contour_type>::relocate_requirements relocate_requirements;
|
||||
typedef db::polygon_edge_iterator< simple_polygon<C>, db::unit_trans<C> > polygon_edge_iterator;
|
||||
typedef db::polygon_contour_iterator< contour_type, db::unit_trans<C> > polygon_contour_iterator;
|
||||
typedef db::object_tag< simple_polygon<C> > tag;
|
||||
|
|
@ -3568,33 +3548,6 @@ void swap (db::simple_polygon<C> &a, db::simple_polygon<C> &b)
|
|||
|
||||
namespace tl
|
||||
{
|
||||
/**
|
||||
* @brief The type traits for the polygon type
|
||||
*/
|
||||
template <class C>
|
||||
struct type_traits <db::polygon<C> > : public type_traits<void>
|
||||
{
|
||||
typedef typename db::polygon<C>::relocate_requirements relocate_requirements;
|
||||
typedef true_tag has_efficient_swap;
|
||||
typedef true_tag supports_extractor;
|
||||
typedef true_tag supports_to_string;
|
||||
typedef true_tag has_less_operator;
|
||||
typedef true_tag has_equal_operator;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief The type traits for the simple_polygon type
|
||||
*/
|
||||
template <class C>
|
||||
struct type_traits <db::simple_polygon<C> > : public type_traits<void>
|
||||
{
|
||||
typedef typename db::simple_polygon<C>::relocate_requirements relocate_requirements;
|
||||
typedef true_tag supports_extractor;
|
||||
typedef true_tag supports_to_string;
|
||||
typedef true_tag has_less_operator;
|
||||
typedef true_tag has_equal_operator;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Special extractors for the polygons
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -1821,21 +1821,5 @@ private:
|
|||
|
||||
} // namespace db
|
||||
|
||||
namespace tl
|
||||
{
|
||||
/**
|
||||
* @brief The type traits for the region type
|
||||
*/
|
||||
template <>
|
||||
struct type_traits <db::Region> : public type_traits<void>
|
||||
{
|
||||
typedef true_tag supports_extractor;
|
||||
typedef true_tag supports_to_string;
|
||||
typedef true_tag has_less_operator;
|
||||
typedef true_tag has_equal_operator;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -100,16 +100,4 @@ public:
|
|||
|
||||
}
|
||||
|
||||
namespace tl
|
||||
{
|
||||
|
||||
template<> struct type_traits<db::ShapeCollection> : public tl::type_traits<void>
|
||||
{
|
||||
// mark "NetlistDeviceExtractor" as having a default ctor and no copy ctor
|
||||
typedef tl::false_tag has_copy_constructor;
|
||||
typedef tl::false_tag has_default_constructor;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -874,16 +874,5 @@ public:
|
|||
|
||||
}
|
||||
|
||||
namespace tl
|
||||
{
|
||||
/**
|
||||
* @brief Type traits
|
||||
*/
|
||||
template <> struct type_traits <db::TechnologyComponent> : public type_traits<void> {
|
||||
typedef tl::false_tag has_default_constructor;
|
||||
typedef tl::false_tag has_copy_constructor;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -1125,15 +1125,6 @@ inline void mem_stat (MemStatistics *stat, MemStatistics::purpose_t purpose, int
|
|||
|
||||
namespace tl
|
||||
{
|
||||
template <class C>
|
||||
struct type_traits <db::text<C> > : public type_traits<void>
|
||||
{
|
||||
typedef true_tag supports_extractor;
|
||||
typedef true_tag supports_to_string;
|
||||
typedef true_tag has_less_operator;
|
||||
typedef true_tag has_equal_operator;
|
||||
};
|
||||
|
||||
template<> void DB_PUBLIC extractor_impl (tl::Extractor &ex, db::Text &p);
|
||||
template<> void DB_PUBLIC extractor_impl (tl::Extractor &ex, db::DText &p);
|
||||
|
||||
|
|
|
|||
|
|
@ -618,21 +618,5 @@ private:
|
|||
|
||||
}
|
||||
|
||||
namespace tl
|
||||
{
|
||||
/**
|
||||
* @brief The type traits for the box type
|
||||
*/
|
||||
template <>
|
||||
struct type_traits <db::Texts> : public type_traits<void>
|
||||
{
|
||||
typedef true_tag supports_extractor;
|
||||
typedef true_tag supports_to_string;
|
||||
typedef true_tag has_less_operator;
|
||||
typedef true_tag has_equal_operator;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -703,15 +703,5 @@ private:
|
|||
|
||||
}
|
||||
|
||||
namespace tl
|
||||
{
|
||||
template <>
|
||||
struct type_traits<db::TilingProcessor> : public type_traits<void>
|
||||
{
|
||||
typedef tl::true_tag has_default_constructor;
|
||||
typedef tl::false_tag has_copy_constructor;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -520,19 +520,6 @@ typedef tl::RegisteredClass<user_object_factory_base<db::DCoord> > DUserObjectDe
|
|||
|
||||
} // namespace db
|
||||
|
||||
namespace tl
|
||||
{
|
||||
/**
|
||||
* @brief The type traits for the user object type
|
||||
*/
|
||||
template <class C>
|
||||
struct type_traits <db::user_object<C> > : public type_traits<void>
|
||||
{
|
||||
typedef trivial_relocate_required relocate_requirements;
|
||||
typedef true_tag has_efficient_swap;
|
||||
};
|
||||
}
|
||||
|
||||
// inject a swap specialization into the std namespace:
|
||||
namespace std
|
||||
{
|
||||
|
|
|
|||
|
|
@ -713,15 +713,6 @@ struct from_double_vector
|
|||
|
||||
namespace tl
|
||||
{
|
||||
template <class C>
|
||||
struct type_traits <db::vector<C> > : public type_traits<void>
|
||||
{
|
||||
typedef true_tag supports_extractor;
|
||||
typedef true_tag supports_to_string;
|
||||
typedef true_tag has_less_operator;
|
||||
typedef true_tag has_equal_operator;
|
||||
};
|
||||
|
||||
template <> DB_PUBLIC void extractor_impl (tl::Extractor &ex, db::Vector &p);
|
||||
template <> DB_PUBLIC void extractor_impl (tl::Extractor &ex, db::DVector &p);
|
||||
|
||||
|
|
|
|||
|
|
@ -369,24 +369,6 @@ private:
|
|||
int m_layer_index_b;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
namespace tl
|
||||
{
|
||||
|
||||
// Disable copy and default ctor for layout query
|
||||
template <>
|
||||
struct type_traits<LayoutDiff>
|
||||
: public type_traits<void>
|
||||
{
|
||||
typedef false_tag has_copy_constructor;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
namespace gsi
|
||||
{
|
||||
|
||||
static unsigned int f_silent () {
|
||||
return db::layout_diff::f_silent;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,29 +24,6 @@
|
|||
#include "gsiDecl.h"
|
||||
#include "dbLayoutQuery.h"
|
||||
|
||||
namespace tl
|
||||
{
|
||||
|
||||
// Disable copy and default ctor for layout query
|
||||
template <>
|
||||
struct type_traits<db::LayoutQuery>
|
||||
: public type_traits<void>
|
||||
{
|
||||
typedef false_tag has_copy_constructor;
|
||||
typedef false_tag has_default_constructor;
|
||||
};
|
||||
|
||||
// Disable copy and default ctor for layout query
|
||||
template <>
|
||||
struct type_traits<db::LayoutQueryIterator>
|
||||
: public type_traits<void>
|
||||
{
|
||||
typedef false_tag has_copy_constructor;
|
||||
typedef false_tag has_default_constructor;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
namespace gsi
|
||||
{
|
||||
|
||||
|
|
|
|||
|
|
@ -316,11 +316,6 @@ private:
|
|||
|
||||
}
|
||||
|
||||
namespace tl
|
||||
{
|
||||
template<> struct type_traits<GenericNetlistCompareLogger> : public tl::type_traits<db::NetlistCompareLogger> { };
|
||||
}
|
||||
|
||||
namespace gsi
|
||||
{
|
||||
|
||||
|
|
|
|||
|
|
@ -93,23 +93,6 @@ public:
|
|||
gsi::Callback cb_extract_devices;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
namespace tl
|
||||
{
|
||||
|
||||
template<> struct type_traits<GenericDeviceExtractor> : public tl::type_traits<void>
|
||||
{
|
||||
// mark "NetlistDeviceExtractor" as having a default ctor and no copy ctor
|
||||
typedef tl::false_tag has_copy_constructor;
|
||||
typedef tl::true_tag has_default_constructor;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
namespace gsi
|
||||
{
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
|
|
|
|||
|
|
@ -44,74 +44,53 @@ namespace gsi
|
|||
/**
|
||||
* @brief A helper function to implement equal as efficiently as possible
|
||||
*/
|
||||
template<class T, class I>
|
||||
bool _var_user_equal_impl (const T *a, const T *b, const VariantUserClassImpl *delegate, I);
|
||||
template<class T, bool> struct _var_user_equal_impl;
|
||||
|
||||
template<class T>
|
||||
bool _var_user_equal_impl (const T *a, const T *b, const VariantUserClassImpl * /*delegate*/, tl::true_tag)
|
||||
struct _var_user_equal_impl<T, true>
|
||||
{
|
||||
return *a == *b;
|
||||
}
|
||||
static bool call (const T *a, const T *b, const VariantUserClassImpl * /*delegate*/) { return *a == *b; }
|
||||
};
|
||||
|
||||
template<class T>
|
||||
bool _var_user_equal_impl (const T *a, const T *b, const VariantUserClassImpl *delegate, tl::false_tag)
|
||||
struct _var_user_equal_impl<T, false>
|
||||
{
|
||||
return delegate->equal_impl ((void *) a, (void *) b);
|
||||
}
|
||||
static bool call (const T *a, const T *b, const VariantUserClassImpl *delegate) { return delegate->equal_impl ((void *) a, (void *) b); }
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief A helper function to implement less as efficiently as possible
|
||||
* @brief A helper function to implement equal as efficiently as possible
|
||||
*/
|
||||
template<class T, class I>
|
||||
bool _var_user_less_impl (const T *a, const T *b, const VariantUserClassImpl *delegate, I);
|
||||
template<class T, bool> struct _var_user_less_impl;
|
||||
|
||||
template<class T>
|
||||
bool _var_user_less_impl (const T *a, const T *b, const VariantUserClassImpl * /*delegate*/, tl::true_tag)
|
||||
struct _var_user_less_impl<T, true>
|
||||
{
|
||||
return *a < *b;
|
||||
}
|
||||
static bool call (const T *a, const T *b, const VariantUserClassImpl * /*delegate*/) { return *a < *b; }
|
||||
};
|
||||
|
||||
template<class T>
|
||||
bool _var_user_less_impl (const T *a, const T *b, const VariantUserClassImpl *delegate, tl::false_tag)
|
||||
struct _var_user_less_impl<T, false>
|
||||
{
|
||||
return delegate->less_impl ((void *) a, (void *) b);
|
||||
}
|
||||
static bool call (const T *a, const T *b, const VariantUserClassImpl *delegate) { return delegate->less_impl ((void *) a, (void *) b); }
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief A helper function to implement to_string as efficiently as possible
|
||||
* @brief A helper function to implement equal as efficiently as possible
|
||||
*/
|
||||
template<class T, class I>
|
||||
std::string _var_user_to_string_impl (const T *a, const VariantUserClassImpl *delegate, I);
|
||||
template<class T, bool> struct _var_user_to_string_impl;
|
||||
|
||||
template<class T>
|
||||
std::string _var_user_to_string_impl (const T *a, const VariantUserClassImpl * /*delegate*/, tl::true_tag)
|
||||
struct _var_user_to_string_impl<T, true>
|
||||
{
|
||||
return a->to_string ();
|
||||
}
|
||||
static std::string call (const T *a, const VariantUserClassImpl * /*delegate*/) { return a->to_string (); }
|
||||
};
|
||||
|
||||
template<class T>
|
||||
std::string _var_user_to_string_impl (const T *a, const VariantUserClassImpl *delegate, tl::false_tag)
|
||||
struct _var_user_to_string_impl<T, false>
|
||||
{
|
||||
return delegate->to_string_impl ((void *) a);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief A helper function to implement read as efficiently as possible
|
||||
*/
|
||||
template<class T, class I>
|
||||
void _var_user_read_impl (T *a, tl::Extractor &ex, I);
|
||||
|
||||
template<class T>
|
||||
void _var_user_read_impl (T *a, tl::Extractor &ex, tl::true_tag)
|
||||
{
|
||||
ex.read (*a);
|
||||
}
|
||||
|
||||
template<class T>
|
||||
void _var_user_read_impl (T * /*a*/, tl::Extractor & /*ex*/, tl::false_tag)
|
||||
{
|
||||
tl_assert (false);
|
||||
}
|
||||
static std::string call (const T *a, const VariantUserClassImpl *delegate) { return delegate->to_string_impl ((void *) a); }
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief A VariantUserClassBase specialization that links GSI classes and Variant classes
|
||||
|
|
@ -165,20 +144,17 @@ public:
|
|||
|
||||
virtual bool equal (const void *a, const void *b) const
|
||||
{
|
||||
typename tl::type_traits<T>::has_equal_operator f;
|
||||
return gsi::_var_user_equal_impl ((const T *) a, (const T *) b, this, f);
|
||||
return gsi::_var_user_equal_impl<T, tl::has_equal_operator<T>::value>::call ((const T *) a, (const T *) b, this);
|
||||
}
|
||||
|
||||
virtual bool less (const void *a, const void *b) const
|
||||
{
|
||||
typename tl::type_traits<T>::has_less_operator f;
|
||||
return gsi::_var_user_less_impl ((const T *) a, (const T *) b, this, f);
|
||||
return gsi::_var_user_less_impl<T, tl::has_less_operator<T>::value>::call ((const T *) a, (const T *) b, this);
|
||||
}
|
||||
|
||||
virtual std::string to_string (const void *a) const
|
||||
{
|
||||
typename tl::type_traits<T>::supports_to_string f;
|
||||
return gsi::_var_user_to_string_impl ((const T *) a, this, f);
|
||||
return gsi::_var_user_to_string_impl<T, tl::has_to_string<T>::value>::call ((const T *) a, this);
|
||||
}
|
||||
|
||||
void *clone (const void *obj) const
|
||||
|
|
@ -212,8 +188,8 @@ public:
|
|||
|
||||
void read (void *a, tl::Extractor &ex) const
|
||||
{
|
||||
typename tl::type_traits<T>::supports_extractor f;
|
||||
gsi::_var_user_read_impl ((T *) a, ex, f);
|
||||
const T *t = a;
|
||||
ex.read (*t);
|
||||
}
|
||||
|
||||
const gsi::ClassBase *gsi_cls () const
|
||||
|
|
@ -244,256 +220,21 @@ private:
|
|||
// -----------------------------------------------------------------------------
|
||||
// GSI implementation
|
||||
|
||||
template <class X>
|
||||
void *_get_vector_of (SerialArgs & /*from*/, const ArgType & /*a*/, void * /*data*/, void (* /*cb*/) (void * /*data*/, void * /*obj*/), tl::false_tag /*has_copy_ctor*/)
|
||||
{
|
||||
tl_assert (false); // cannot copy object of this type
|
||||
return 0;
|
||||
}
|
||||
template <class X, bool> struct _destroy;
|
||||
template <class X> struct _destroy<X, false> { static void call (X *) { tl_assert (false); } };
|
||||
template <class X> struct _destroy<X, true> { static void call (X *x) { delete x; } };
|
||||
|
||||
template <class X>
|
||||
void _get_vector_of (SerialArgs &from, const ArgType &a, void *data, void (*cb) (void *data, void *obj), tl::true_tag /*has_copy_ctor*/)
|
||||
{
|
||||
std::vector<X> vv;
|
||||
const std::vector<X> *v = &vv;
|
||||
if (a.is_cref ()) {
|
||||
v = &from.template read<const std::vector<X> &> ();
|
||||
} else if (a.is_cptr ()) {
|
||||
v = from.template read<const std::vector<X> *> ();
|
||||
} else if (a.is_ref ()) {
|
||||
v = &from.template read<std::vector<X> &> ();
|
||||
} else if (a.is_ptr ()) {
|
||||
v = from.template read<std::vector<X> *> ();
|
||||
} else {
|
||||
vv = from.template read< std::vector<X> > ();
|
||||
}
|
||||
for (typename std::vector<X>::const_iterator o = v->begin (); o != v->end (); ++o) {
|
||||
(*cb) (data, new X (*o));
|
||||
}
|
||||
}
|
||||
template <class X, bool> struct _create;
|
||||
template <class X> struct _create<X, false> { static void *call () { throw tl::Exception (tl::to_string (tr ("Object cannot be created here"))); } };
|
||||
template <class X> struct _create<X, true> { static void *call () { return new X (); } };
|
||||
|
||||
template <class X>
|
||||
void _get_cptr_vector_of (SerialArgs &from, const ArgType &a, void *data, void (*cb) (void *data, void *obj))
|
||||
{
|
||||
std::vector<const X *> vv;
|
||||
const std::vector<const X *> *v = &vv;
|
||||
if (a.is_cref ()) {
|
||||
v = &from.template read<const std::vector<const X *> &> ();
|
||||
} else if (a.is_cptr ()) {
|
||||
v = from.template read<const std::vector<const X *> *> ();
|
||||
} else if (a.is_ref ()) {
|
||||
v = &from.template read<std::vector<const X *> &> ();
|
||||
} else if (a.is_ptr ()) {
|
||||
v = from.template read<std::vector<const X *> *> ();
|
||||
} else {
|
||||
vv = from.template read< std::vector<const X *> > ();
|
||||
}
|
||||
for (typename std::vector<const X *>::const_iterator o = v->begin (); o != v->end (); ++o) {
|
||||
(*cb) (data, (void *) *o);
|
||||
}
|
||||
}
|
||||
template <class X, bool> struct _clone;
|
||||
template <class X> struct _clone<X, false> { static void *call (const void *) { throw tl::Exception (tl::to_string (tr ("Object cannot be copied here"))); } };
|
||||
template <class X> struct _clone<X, true> { static void *call (const void *other) { new X (*(const X *)other); } };
|
||||
|
||||
template <class X>
|
||||
void _get_ptr_vector_of (SerialArgs &from, const ArgType &a, void *data, void (*cb) (void *data, void *obj))
|
||||
{
|
||||
std::vector<X *> vv;
|
||||
const std::vector<X *> *v = &vv;
|
||||
if (a.is_cref ()) {
|
||||
v = &from.template read<const std::vector<X *> &> ();
|
||||
} else if (a.is_cptr ()) {
|
||||
v = from.template read<const std::vector<X *> *> ();
|
||||
} else if (a.is_ref ()) {
|
||||
v = &from.template read<std::vector<X *> &> ();
|
||||
} else if (a.is_ptr ()) {
|
||||
v = from.template read<std::vector<X *> *> ();
|
||||
} else {
|
||||
vv = from.template read< std::vector<X *> > ();
|
||||
}
|
||||
for (typename std::vector<X *>::const_iterator o = v->begin (); o != v->end (); ++o) {
|
||||
(*cb) (data, *o);
|
||||
}
|
||||
}
|
||||
|
||||
template <class X>
|
||||
void _destroy (X *, tl::false_tag /*has public dtor*/)
|
||||
{
|
||||
tl_assert (false); // cannot delete object of this type
|
||||
}
|
||||
|
||||
template <class X>
|
||||
void _destroy (X *x, tl::true_tag /*has public dtor*/)
|
||||
{
|
||||
delete x;
|
||||
}
|
||||
|
||||
template <class X>
|
||||
void _push_vector_of (SerialArgs & /*to*/, const ArgType & /*a*/, tl::Heap & /*heap*/, const std::vector<void *> & /*objects*/, tl::false_tag /*has_copy_ctor*/)
|
||||
{
|
||||
tl_assert (false); // cannot copy object of this type
|
||||
}
|
||||
|
||||
template <class X>
|
||||
void _push_vector_of (SerialArgs &to, const ArgType &a, tl::Heap &heap, const std::vector<void *> &objects, tl::true_tag /*has_copy_ctor*/)
|
||||
{
|
||||
tl_assert (a.inner () != 0);
|
||||
|
||||
std::vector<X> vv;
|
||||
std::vector<X> *v;
|
||||
if (a.is_ref () || a.is_cref () || a.is_ptr () || a.is_cptr ()) {
|
||||
v = new std::vector<X> ();
|
||||
heap.push (v);
|
||||
} else {
|
||||
v = &vv;
|
||||
}
|
||||
|
||||
v->reserve (objects.size ());
|
||||
for (std::vector<void *>::const_iterator o = objects.begin (); o != objects.end (); ++o) {
|
||||
v->push_back (*(X *)*o);
|
||||
}
|
||||
|
||||
if (a.is_cref ()) {
|
||||
to.write<const std::vector<X> &> (*v);
|
||||
} else if (a.is_cptr ()) {
|
||||
to.write<const std::vector<X> *> (v);
|
||||
} else if (a.is_ref ()) {
|
||||
to.write<std::vector<X> &> (*v);
|
||||
} else if (a.is_ptr ()) {
|
||||
to.write<std::vector<X> *> (v);
|
||||
} else {
|
||||
to.write<std::vector<X> > (vv);
|
||||
}
|
||||
}
|
||||
|
||||
template <class X>
|
||||
void _push_cptr_vector_of (SerialArgs &to, const ArgType &a, tl::Heap &heap, const std::vector<void *> &objects)
|
||||
{
|
||||
tl_assert (a.inner () != 0);
|
||||
|
||||
std::vector<const X *> vv;
|
||||
std::vector<const X *> *v;
|
||||
if (a.is_ref () || a.is_cref () || a.is_ptr () || a.is_cptr ()) {
|
||||
v = new std::vector<const X *> ();
|
||||
heap.push (v);
|
||||
} else {
|
||||
v = &vv;
|
||||
}
|
||||
|
||||
v->reserve (objects.size ());
|
||||
for (std::vector<void *>::const_iterator o = objects.begin (); o != objects.end (); ++o) {
|
||||
v->push_back ((const X *)*o);
|
||||
}
|
||||
|
||||
if (a.is_cref ()) {
|
||||
to.write<const std::vector<const X *> &> (*v);
|
||||
} else if (a.is_cptr ()) {
|
||||
to.write<const std::vector<const X *> *> (v);
|
||||
} else if (a.is_ref ()) {
|
||||
to.write<std::vector<const X *> &> (*v);
|
||||
} else if (a.is_ptr ()) {
|
||||
to.write<std::vector<const X *> *> (v);
|
||||
} else {
|
||||
to.write<std::vector<const X *> > (vv);
|
||||
}
|
||||
}
|
||||
|
||||
template <class X>
|
||||
void _push_ptr_vector_of (SerialArgs &to, const ArgType &a, tl::Heap &heap, const std::vector<void *> &objects)
|
||||
{
|
||||
tl_assert (a.inner () != 0);
|
||||
|
||||
std::vector<X *> vv;
|
||||
std::vector<X *> *v;
|
||||
if (a.is_ref () || a.is_cref () || a.is_ptr () || a.is_cptr ()) {
|
||||
v = new std::vector<X *> ();
|
||||
heap.push (v);
|
||||
} else {
|
||||
v = &vv;
|
||||
}
|
||||
|
||||
v->reserve (objects.size ());
|
||||
for (std::vector<void *>::const_iterator o = objects.begin (); o != objects.end (); ++o) {
|
||||
v->push_back ((X *)*o);
|
||||
}
|
||||
|
||||
if (a.is_cref ()) {
|
||||
to.write<const std::vector<X *> &> (*v);
|
||||
} else if (a.is_cptr ()) {
|
||||
to.write<const std::vector<X *> *> (v);
|
||||
} else if (a.is_ref ()) {
|
||||
to.write<std::vector<X *> &> (*v);
|
||||
} else if (a.is_ptr ()) {
|
||||
to.write<std::vector<X *> *> (v);
|
||||
} else {
|
||||
to.write<std::vector<X *> > (vv);
|
||||
}
|
||||
}
|
||||
|
||||
template <class X>
|
||||
void *_create (tl::false_tag)
|
||||
{
|
||||
throw tl::Exception (tl::to_string (tr ("Object cannot be created here")));
|
||||
return 0;
|
||||
}
|
||||
|
||||
template <class X>
|
||||
void *_create (tl::true_tag)
|
||||
{
|
||||
return new X ();
|
||||
}
|
||||
|
||||
template <class X>
|
||||
void *_clone (tl::false_tag, const void * /*other*/)
|
||||
{
|
||||
throw tl::Exception (tl::to_string (tr ("Object cannot be copied here")));
|
||||
return 0;
|
||||
}
|
||||
|
||||
template <class X>
|
||||
void *_clone (tl::true_tag, const void *other)
|
||||
{
|
||||
return new X (*(const X *)other);
|
||||
}
|
||||
|
||||
template <class X>
|
||||
void _assign (tl::false_tag /*has_copy_ctor*/, void *, const void *)
|
||||
{
|
||||
throw tl::Exception (tl::to_string (tr ("Object cannot be copied here")));
|
||||
}
|
||||
|
||||
template <class X>
|
||||
void _assign (tl::true_tag /*has_copy_ctor*/, void *dest, const void *src)
|
||||
{
|
||||
*(X *)dest = *(const X *)src;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief A class predicate telling us whether X is polymorphic
|
||||
*
|
||||
* The trick was taken from boost - if a class is made polymorphic and it
|
||||
* has not been before, the size of the object changes since a virtual
|
||||
* function table will be added.
|
||||
*/
|
||||
template <class X>
|
||||
struct is_polymorphic
|
||||
{
|
||||
private:
|
||||
struct P1 : public X
|
||||
{
|
||||
P1 ();
|
||||
~P1 ();
|
||||
int something;
|
||||
};
|
||||
|
||||
struct P2 : public X
|
||||
{
|
||||
P2 ();
|
||||
virtual ~P2 ();
|
||||
int something;
|
||||
};
|
||||
|
||||
public:
|
||||
typedef typename tl::boolean_value<sizeof (P1) == sizeof (P2)>::value value;
|
||||
};
|
||||
template <class X, bool> struct _assign;
|
||||
template <class X> struct _assign<X, false> { static void call (void *, const void *) { throw tl::Exception (tl::to_string (tr ("Object cannot be copied here"))); } };
|
||||
template <class X> struct _assign<X, true> { static void call (void *dest, const void *src) { *(X *)dest = *(const X *)src; } };
|
||||
|
||||
/**
|
||||
* @brief A helper class which tests whether a given object can be upcast
|
||||
|
|
@ -513,14 +254,14 @@ public:
|
|||
* The can_upcast method will return true, if the object (which has at least to
|
||||
* be of type B) can be upcast to X.
|
||||
*/
|
||||
template <class X, class B, class B_IS_POLYMORPHIC>
|
||||
template <class X, class B, bool B_IS_POLYMORPHIC>
|
||||
class SubClassTester;
|
||||
|
||||
/**
|
||||
* @brief Specialization for polymorphic types - we can use dynamic_cast to tests whether B object can be cast to X
|
||||
*/
|
||||
template <class X, class B>
|
||||
class SubClassTester<X, B, tl::true_tag>
|
||||
class SubClassTester<X, B, true>
|
||||
: public SubClassTesterBase
|
||||
{
|
||||
public:
|
||||
|
|
@ -534,7 +275,7 @@ public:
|
|||
* @brief Specialization for non-polymorphic types
|
||||
*/
|
||||
template <class X, class B>
|
||||
class SubClassTester<X, B, tl::false_tag>
|
||||
class SubClassTester<X, B, false>
|
||||
: public SubClassTesterBase
|
||||
{
|
||||
public:
|
||||
|
|
@ -556,10 +297,6 @@ class GSI_PUBLIC_TEMPLATE ClassExt
|
|||
: public ClassBase
|
||||
{
|
||||
public:
|
||||
typedef typename tl::type_traits<X>::has_copy_constructor has_copy_ctor;
|
||||
typedef typename tl::type_traits<X>::has_default_constructor has_default_ctor;
|
||||
typedef typename tl::type_traits<X>::has_public_destructor has_public_dtor;
|
||||
|
||||
ClassExt (const Methods &mm, const std::string &doc = std::string ())
|
||||
: ClassBase (doc, mm), mp_declaration (0)
|
||||
{
|
||||
|
|
@ -713,10 +450,6 @@ class GSI_PUBLIC_TEMPLATE Class
|
|||
: public ClassBase
|
||||
{
|
||||
public:
|
||||
typedef typename tl::type_traits<X>::has_copy_constructor has_copy_ctor;
|
||||
typedef typename tl::type_traits<X>::has_default_constructor has_default_ctor;
|
||||
typedef typename tl::type_traits<X>::has_public_destructor has_public_dtor;
|
||||
|
||||
Class (const std::string &module, const std::string &name, const Methods &mm, const std::string &doc = std::string (), bool do_register = true)
|
||||
: ClassBase (doc, mm, do_register)
|
||||
{
|
||||
|
|
@ -726,7 +459,7 @@ public:
|
|||
|
||||
template <class B>
|
||||
Class (const Class<B> &base, const std::string &module, const std::string &name, const Methods &mm, const std::string &doc = std::string (), bool do_register = true)
|
||||
: ClassBase (doc, mm, do_register), m_subclass_tester (new SubClassTester<X, B, typename is_polymorphic<B>::value> ())
|
||||
: ClassBase (doc, mm, do_register), m_subclass_tester (new SubClassTester<X, B, std::is_polymorphic<B>::value> ())
|
||||
{
|
||||
set_module (module);
|
||||
set_name (name);
|
||||
|
|
@ -742,7 +475,7 @@ public:
|
|||
|
||||
template <class B>
|
||||
Class (const Class<B> &base, const std::string &module, const std::string &name, const std::string &doc = std::string (), bool do_register = true)
|
||||
: ClassBase (doc, Methods (), do_register), m_subclass_tester (new SubClassTester<X, B, typename is_polymorphic<B>::value> ())
|
||||
: ClassBase (doc, Methods (), do_register), m_subclass_tester (new SubClassTester<X, B, std::is_polymorphic<B>::value> ())
|
||||
{
|
||||
set_module (module);
|
||||
set_name (name);
|
||||
|
|
@ -785,15 +518,12 @@ public:
|
|||
virtual void destroy (void *p) const
|
||||
{
|
||||
X *x = (X *)p;
|
||||
has_public_dtor hpd;
|
||||
_destroy (x, hpd);
|
||||
_destroy<X, std::is_destructible<X>::value>::call (x);
|
||||
}
|
||||
|
||||
virtual void *create () const
|
||||
{
|
||||
has_default_ctor cst;
|
||||
void *r = _create<X> (cst);
|
||||
return r;
|
||||
return _create<X, std::is_default_constructible<X>::value>::call ();
|
||||
}
|
||||
|
||||
virtual void *create_from_adapted (const void *x) const
|
||||
|
|
@ -818,33 +548,27 @@ public:
|
|||
|
||||
virtual void *clone (const void *other) const
|
||||
{
|
||||
has_copy_ctor cst;
|
||||
void *r = _clone<X> (cst, other);
|
||||
return r;
|
||||
return _clone<X, std::is_copy_constructible<X>::value>::call (other);
|
||||
}
|
||||
|
||||
virtual void assign (void *dest, const void *src) const
|
||||
{
|
||||
has_copy_ctor cst;
|
||||
_assign<X> (cst, dest, src);
|
||||
_assign<X, std::is_copy_assignable<X>::value>::call (dest, src);
|
||||
}
|
||||
|
||||
virtual bool can_destroy () const
|
||||
{
|
||||
has_public_dtor hpd;
|
||||
return tl::value_of (hpd);
|
||||
return std::is_destructible<X>::value;
|
||||
}
|
||||
|
||||
virtual bool can_copy () const
|
||||
{
|
||||
has_copy_ctor cpt;
|
||||
return tl::value_of (cpt);
|
||||
return std::is_copy_constructible<X>::value;
|
||||
}
|
||||
|
||||
virtual bool can_default_create () const
|
||||
{
|
||||
has_default_ctor cpt;
|
||||
return tl::value_of (cpt);
|
||||
return std::is_default_constructible<X>::value;
|
||||
}
|
||||
|
||||
virtual const ClassBase *subclass_decl (const void *p) const
|
||||
|
|
|
|||
|
|
@ -26,17 +26,6 @@
|
|||
#include "gsiDecl.h"
|
||||
#include "tlTypeTraits.h"
|
||||
|
||||
namespace tl
|
||||
{
|
||||
template <> struct type_traits<gsi::Interpreter>
|
||||
: tl::type_traits<void>
|
||||
{
|
||||
typedef false_tag has_copy_constructor;
|
||||
typedef false_tag has_default_constructor;
|
||||
typedef false_tag has_public_destructor;
|
||||
};
|
||||
}
|
||||
|
||||
namespace gsi
|
||||
{
|
||||
|
||||
|
|
|
|||
|
|
@ -23,21 +23,6 @@
|
|||
|
||||
#include "gsiDecl.h"
|
||||
|
||||
namespace tl
|
||||
{
|
||||
|
||||
template <> struct type_traits<gsi::ClassBase> : public type_traits<void> {
|
||||
typedef tl::false_tag has_copy_constructor;
|
||||
typedef tl::false_tag has_default_constructor;
|
||||
};
|
||||
|
||||
template <> struct type_traits<gsi::MethodBase> : public type_traits<void> {
|
||||
typedef tl::false_tag has_copy_constructor;
|
||||
typedef tl::false_tag has_default_constructor;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
namespace gsi
|
||||
{
|
||||
|
||||
|
|
|
|||
|
|
@ -77,18 +77,6 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
namespace tl {
|
||||
template <> struct type_traits<gsi::Logger> : public type_traits<void> {
|
||||
typedef tl::false_tag has_copy_constructor;
|
||||
typedef tl::false_tag has_default_constructor;
|
||||
};
|
||||
}
|
||||
|
||||
namespace gsi
|
||||
{
|
||||
|
||||
Class<Logger> decl_Logger ("tl", "Logger",
|
||||
gsi::method ("info", &Logger::info, gsi::arg ("msg"),
|
||||
"@brief Writes the given string to the info channel\n"
|
||||
|
|
@ -488,20 +476,6 @@ static ExpressionWrapper *new_expr2 (const std::string &e, const std::map<std::s
|
|||
return expr.release ();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
namespace tl {
|
||||
|
||||
template <> struct type_traits<ExpressionWrapper> : public type_traits<void> {
|
||||
typedef tl::false_tag has_copy_constructor;
|
||||
typedef tl::true_tag has_default_constructor;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
namespace gsi
|
||||
{
|
||||
|
||||
Class<tl::Eval> decl_ExpressionContext ("tl", "ExpressionContext",
|
||||
gsi::method ("var", &tl::Eval::set_var, gsi::arg ("name"), gsi::arg ("value"),
|
||||
"@brief Defines a variable with the given name and value\n"
|
||||
|
|
|
|||
|
|
@ -1144,7 +1144,7 @@ public:
|
|||
/**
|
||||
* @brief An implementation helper that provides a switch between classes having and having no copy ctor
|
||||
*/
|
||||
template <class T, class CC>
|
||||
template <class T, bool>
|
||||
class ArgSpecImpl
|
||||
: public ArgSpecBase
|
||||
{
|
||||
|
|
@ -1189,7 +1189,7 @@ public:
|
|||
* @brief A specialization for classes with default and copy ctor
|
||||
*/
|
||||
template <class T>
|
||||
class ArgSpecImpl<T, tl::true_tag>
|
||||
class ArgSpecImpl<T, true>
|
||||
: public ArgSpecBase
|
||||
{
|
||||
public:
|
||||
|
|
@ -1289,30 +1289,30 @@ private:
|
|||
*/
|
||||
template <class T>
|
||||
class ArgSpec
|
||||
: public ArgSpecImpl<T, typename tl::type_traits<T>::has_copy_constructor>
|
||||
: public ArgSpecImpl<T, std::is_copy_constructible<T>::value && std::is_destructible<T>::value>
|
||||
{
|
||||
public:
|
||||
typedef typename tl::type_traits<T>::has_copy_constructor cc_type;
|
||||
typedef ArgSpecImpl<T, std::is_copy_constructible<T>::value && std::is_destructible<T>::value> Base;
|
||||
|
||||
ArgSpec ()
|
||||
: ArgSpecImpl<T, cc_type> ()
|
||||
: Base ()
|
||||
{ }
|
||||
|
||||
ArgSpec (const ArgSpec<void> &other)
|
||||
: ArgSpecImpl<T, cc_type> (other)
|
||||
: Base (other)
|
||||
{ }
|
||||
|
||||
template <class Q>
|
||||
ArgSpec (const ArgSpec<Q> &other)
|
||||
: ArgSpecImpl<T, cc_type> (other)
|
||||
: Base (other)
|
||||
{ }
|
||||
|
||||
ArgSpec (const std::string &name)
|
||||
: ArgSpecImpl<T, cc_type> (name)
|
||||
: Base (name)
|
||||
{ }
|
||||
|
||||
ArgSpec (const std::string &name, const T &init, const std::string &init_doc = std::string ())
|
||||
: ArgSpecImpl<T, cc_type> (name, init, init_doc)
|
||||
: Base (name, init, init_doc)
|
||||
{ }
|
||||
|
||||
virtual ArgSpecBase *clone () const
|
||||
|
|
@ -1326,30 +1326,30 @@ public:
|
|||
*/
|
||||
template <class T>
|
||||
class ArgSpec<const T &>
|
||||
: public ArgSpecImpl<T, typename tl::type_traits<T>::has_copy_constructor>
|
||||
: public ArgSpecImpl<T, std::is_copy_constructible<T>::value && std::is_destructible<T>::value>
|
||||
{
|
||||
public:
|
||||
typedef typename tl::type_traits<T>::has_copy_constructor cc_type;
|
||||
typedef ArgSpecImpl<T, std::is_copy_constructible<T>::value && std::is_destructible<T>::value> Base;
|
||||
|
||||
ArgSpec ()
|
||||
: ArgSpecImpl<T, cc_type> ()
|
||||
ArgSpec ()
|
||||
: Base ()
|
||||
{ }
|
||||
|
||||
ArgSpec (const ArgSpec<void> &other)
|
||||
: ArgSpecImpl<T, cc_type> (other)
|
||||
: Base (other)
|
||||
{ }
|
||||
|
||||
template <class Q>
|
||||
ArgSpec (const ArgSpec<Q> &other)
|
||||
: ArgSpecImpl<T, cc_type> (other)
|
||||
: Base (other)
|
||||
{ }
|
||||
|
||||
ArgSpec (const std::string &name)
|
||||
: ArgSpecImpl<T, cc_type> (name)
|
||||
: Base (name)
|
||||
{ }
|
||||
|
||||
ArgSpec (const std::string &name, const T &init, const std::string &init_doc = std::string ())
|
||||
: ArgSpecImpl<T, cc_type> (name, init, init_doc)
|
||||
: Base (name, init, init_doc)
|
||||
{ }
|
||||
|
||||
virtual ArgSpecBase *clone () const
|
||||
|
|
@ -1363,37 +1363,37 @@ public:
|
|||
*/
|
||||
template <class T>
|
||||
class ArgSpec<T &>
|
||||
: public ArgSpecImpl<T, typename tl::type_traits<T>::has_copy_constructor>
|
||||
: public ArgSpecImpl<T, std::is_copy_constructible<T>::value && std::is_destructible<T>::value>
|
||||
{
|
||||
public:
|
||||
typedef ArgSpecImpl<T, std::is_copy_constructible<T>::value && std::is_destructible<T>::value> Base;
|
||||
typedef T &init_type;
|
||||
typedef typename tl::type_traits<T>::has_copy_constructor cc_type;
|
||||
|
||||
ArgSpec ()
|
||||
: ArgSpecImpl<T, cc_type> ()
|
||||
: Base ()
|
||||
{ }
|
||||
|
||||
ArgSpec (const ArgSpec<void> &other)
|
||||
: ArgSpecImpl<T, cc_type> (other)
|
||||
: Base (other)
|
||||
{ }
|
||||
|
||||
template <class Q>
|
||||
ArgSpec (const ArgSpec<Q> &other)
|
||||
: ArgSpecImpl<T, cc_type> (other)
|
||||
: Base (other)
|
||||
{ }
|
||||
|
||||
ArgSpec (const std::string &name)
|
||||
: ArgSpecImpl<T, cc_type> (name)
|
||||
: Base (name)
|
||||
{ }
|
||||
|
||||
ArgSpec (const std::string &name, const T &init, const std::string &init_doc = std::string ())
|
||||
: ArgSpecImpl<T, cc_type> (name, init, init_doc)
|
||||
: Base (name, init, init_doc)
|
||||
{ }
|
||||
|
||||
T &init () const
|
||||
{
|
||||
// this simplifies the implementation, but it's not really clean since the caller may modify the default.
|
||||
return const_cast<T &> (ArgSpecImpl<T, cc_type>::init ());
|
||||
return const_cast<T &> (ArgSpecImpl<T, std::is_copy_constructible<T>::value>::init ());
|
||||
}
|
||||
|
||||
virtual ArgSpecBase *clone () const
|
||||
|
|
|
|||
|
|
@ -1273,17 +1273,5 @@ private:
|
|||
|
||||
}
|
||||
|
||||
namespace tl
|
||||
{
|
||||
template <> struct type_traits<gsi_test::A_NC> : public type_traits<void> {
|
||||
typedef tl::false_tag has_copy_constructor;
|
||||
};
|
||||
#if defined(HAVE_QT)
|
||||
template <> struct type_traits<gsi_test::SQ> : public type_traits<void> {
|
||||
typedef tl::false_tag has_copy_constructor;
|
||||
};
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -34,18 +34,6 @@
|
|||
# define QT_EXTERNAL_BASE(x)
|
||||
#endif
|
||||
|
||||
namespace tl
|
||||
{
|
||||
|
||||
// type traits for HelpDialog
|
||||
template <>
|
||||
struct type_traits<lay::HelpDialog> : public type_traits<void> {
|
||||
typedef tl::false_tag has_default_constructor;
|
||||
typedef tl::false_tag has_copy_constructor;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
namespace gsi
|
||||
{
|
||||
|
||||
|
|
|
|||
|
|
@ -494,20 +494,6 @@ private:
|
|||
|
||||
} // namespace lay
|
||||
|
||||
namespace tl {
|
||||
|
||||
template <> struct type_traits<lay::GuiApplication> : public type_traits<void> {
|
||||
typedef tl::false_tag has_copy_constructor;
|
||||
typedef tl::false_tag has_default_constructor;
|
||||
};
|
||||
|
||||
template <> struct type_traits<lay::NonGuiApplication> : public type_traits<void> {
|
||||
typedef tl::false_tag has_copy_constructor;
|
||||
typedef tl::false_tag has_default_constructor;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -833,11 +833,4 @@ private:
|
|||
|
||||
}
|
||||
|
||||
namespace tl {
|
||||
template <> struct type_traits<lay::MainWindow> : public type_traits<void> {
|
||||
typedef tl::false_tag has_copy_constructor;
|
||||
typedef tl::false_tag has_default_constructor;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -92,29 +92,6 @@ public:
|
|||
gsi::Callback get_cb;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
namespace tl
|
||||
{
|
||||
|
||||
// type traits for BrowserDialog_Stub
|
||||
template <>
|
||||
struct type_traits<gsi::BrowserDialog_Stub> : public type_traits<void> {
|
||||
typedef tl::false_tag has_copy_constructor;
|
||||
};
|
||||
|
||||
// type traits for BrowserPanel
|
||||
template <>
|
||||
struct type_traits<lay::BrowserPanel> : public type_traits<void> {
|
||||
typedef tl::false_tag has_default_constructor;
|
||||
typedef tl::false_tag has_copy_constructor;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
namespace gsi
|
||||
{
|
||||
|
||||
// ---------------------------------------------------------------------------------
|
||||
// Value classes with "not set" capabilities
|
||||
|
||||
|
|
|
|||
|
|
@ -24,18 +24,6 @@
|
|||
#include "gsiDecl.h"
|
||||
#include "layLayoutView.h"
|
||||
|
||||
namespace tl
|
||||
{
|
||||
// NOTE: we don't want references to be passed around and be default-constructed.
|
||||
// References are only meant as return values for the layer properties iterator and
|
||||
// be short-living. Hence we disable copying (which will also disable the default
|
||||
// "assign" implementation) and default construction.
|
||||
template <> struct type_traits<lay::LayerPropertiesNodeRef> : public type_traits<void> {
|
||||
typedef tl::false_tag has_copy_constructor;
|
||||
typedef tl::false_tag has_default_constructor;
|
||||
};
|
||||
}
|
||||
|
||||
namespace gsi
|
||||
{
|
||||
|
||||
|
|
|
|||
|
|
@ -44,18 +44,6 @@ public:
|
|||
tl::Event on_triggered_event;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
namespace tl
|
||||
{
|
||||
template <> struct type_traits<ActionStub> : public type_traits<void> {
|
||||
typedef tl::false_tag has_copy_constructor;
|
||||
};
|
||||
}
|
||||
|
||||
namespace gsi
|
||||
{
|
||||
|
||||
static std::string pack_key_binding (const std::map<std::string, std::string> &kb)
|
||||
{
|
||||
std::vector<std::pair<std::string, std::string> > v;
|
||||
|
|
|
|||
|
|
@ -27,18 +27,6 @@
|
|||
#include "layNetlistBrowserDialog.h"
|
||||
#include "layLayoutView.h"
|
||||
|
||||
namespace tl
|
||||
{
|
||||
|
||||
// disable copy and default constructor for NetlistBrowserDialog
|
||||
template <> struct type_traits<lay::NetlistBrowserDialog> : public type_traits<void>
|
||||
{
|
||||
typedef tl::false_tag has_copy_constructor;
|
||||
typedef tl::false_tag has_default_constructor;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
namespace gsi
|
||||
{
|
||||
|
||||
|
|
|
|||
|
|
@ -32,21 +32,6 @@ namespace gsi
|
|||
{
|
||||
class PluginFactoryBase;
|
||||
class PluginBase;
|
||||
}
|
||||
|
||||
namespace tl
|
||||
{
|
||||
template <> struct type_traits<gsi::PluginFactoryBase> : public type_traits<void> {
|
||||
typedef tl::false_tag has_copy_constructor;
|
||||
};
|
||||
|
||||
template <> struct type_traits<gsi::PluginBase> : public type_traits<void> {
|
||||
typedef tl::false_tag has_copy_constructor;
|
||||
};
|
||||
}
|
||||
|
||||
namespace gsi
|
||||
{
|
||||
|
||||
// TODO: these static variables are a bad hack!
|
||||
// However it's not easy to pass parameters to a C++ classes constructor in Ruby without
|
||||
|
|
|
|||
|
|
@ -63,15 +63,6 @@
|
|||
// --------------------------------------------------------------
|
||||
// A helper class that allows putting a QImage into a tl::Variant
|
||||
|
||||
namespace tl
|
||||
{
|
||||
template <>
|
||||
struct type_traits <QImage> : public type_traits<void>
|
||||
{
|
||||
typedef true_tag has_equal_operator;
|
||||
};
|
||||
}
|
||||
|
||||
namespace gtf
|
||||
{
|
||||
|
||||
|
|
|
|||
|
|
@ -822,23 +822,6 @@ private:
|
|||
|
||||
}
|
||||
|
||||
namespace tl
|
||||
{
|
||||
template <> struct type_traits<lay::AbstractMenu> : public type_traits<void> {
|
||||
typedef tl::false_tag has_copy_constructor;
|
||||
typedef tl::false_tag has_default_constructor;
|
||||
};
|
||||
|
||||
template <> struct type_traits<lay::AbstractMenuItem> : public type_traits<void> {
|
||||
typedef tl::false_tag has_copy_constructor;
|
||||
typedef tl::false_tag has_default_constructor;
|
||||
};
|
||||
|
||||
template <> struct type_traits<lay::Action> : public type_traits<void> {
|
||||
typedef tl::false_tag has_copy_constructor;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -130,16 +130,5 @@ private:
|
|||
|
||||
}
|
||||
|
||||
namespace tl
|
||||
{
|
||||
template <> struct type_traits<lay::BrowserDialog> : public type_traits<void> {
|
||||
typedef tl::false_tag has_copy_constructor;
|
||||
};
|
||||
|
||||
template <> struct type_traits<lay::BrowserSource> : public type_traits<void> {
|
||||
typedef tl::false_tag has_copy_constructor;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -246,15 +246,4 @@ private:
|
|||
|
||||
}
|
||||
|
||||
namespace tl
|
||||
{
|
||||
// disable copy ctor for Dispatcher
|
||||
template <> struct type_traits<lay::Dispatcher> : public type_traits<void> {
|
||||
typedef tl::false_tag has_copy_constructor;
|
||||
typedef tl::false_tag has_default_constructor;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -2934,12 +2934,4 @@ private:
|
|||
|
||||
}
|
||||
|
||||
namespace tl {
|
||||
template <> struct type_traits<lay::LayoutView> : public type_traits<void> {
|
||||
typedef tl::false_tag has_copy_constructor;
|
||||
typedef tl::false_tag has_default_constructor;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -813,17 +813,4 @@ private:
|
|||
|
||||
}
|
||||
|
||||
namespace tl {
|
||||
template <> struct type_traits<lay::Marker> : public type_traits<void> {
|
||||
typedef tl::false_tag has_copy_constructor;
|
||||
typedef tl::false_tag has_default_constructor;
|
||||
};
|
||||
template <> struct type_traits<lay::DMarker> : public type_traits<void> {
|
||||
typedef tl::false_tag has_copy_constructor;
|
||||
typedef tl::false_tag has_default_constructor;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -99,19 +99,6 @@ class CircuitNetItemData;
|
|||
class CircuitDeviceItemData;
|
||||
class CircuitSubCircuitItemData;
|
||||
|
||||
}
|
||||
|
||||
namespace tl {
|
||||
// disable copying for NetlistModelItemData
|
||||
template<> struct type_traits<lay::NetlistModelItemData>
|
||||
{
|
||||
typedef false_tag has_copy_constructor;
|
||||
};
|
||||
}
|
||||
|
||||
namespace lay
|
||||
{
|
||||
|
||||
/**
|
||||
* @brief A base class for the item data object
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -883,14 +883,6 @@ inline bool test_and_set (T &target, const T &source)
|
|||
|
||||
}
|
||||
|
||||
namespace tl
|
||||
{
|
||||
// disable copy ctor for Plugin
|
||||
template <> struct type_traits<lay::Plugin> : public type_traits<void> {
|
||||
typedef tl::false_tag has_copy_constructor;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -35,17 +35,6 @@
|
|||
|
||||
#include <cstdio>
|
||||
|
||||
namespace tl
|
||||
{
|
||||
|
||||
// type traits for BrowserDialog_Stub
|
||||
template <>
|
||||
struct type_traits<lym::Macro> : public type_traits<void> {
|
||||
typedef tl::false_tag has_copy_constructor;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
namespace gsi
|
||||
{
|
||||
|
||||
|
|
|
|||
|
|
@ -2388,48 +2388,4 @@ private:
|
|||
|
||||
}
|
||||
|
||||
namespace tl
|
||||
{
|
||||
/**
|
||||
* @brief Type traits for Cell
|
||||
*/
|
||||
template <> struct type_traits<rdb::Cell> : public type_traits<void> {
|
||||
typedef tl::false_tag has_copy_constructor;
|
||||
typedef tl::false_tag has_default_constructor;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Type traits for Category
|
||||
*/
|
||||
template <> struct type_traits<rdb::Category> : public type_traits<void> {
|
||||
typedef tl::false_tag has_copy_constructor;
|
||||
typedef tl::false_tag has_default_constructor;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Type traits for Categories
|
||||
*/
|
||||
template <> struct type_traits<rdb::Categories> : public type_traits<void> {
|
||||
typedef tl::false_tag has_copy_constructor;
|
||||
typedef tl::false_tag has_default_constructor;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Type traits for Item
|
||||
*/
|
||||
template <> struct type_traits<rdb::Item> : public type_traits<void> {
|
||||
typedef tl::false_tag has_copy_constructor;
|
||||
typedef tl::false_tag has_default_constructor;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Type traits for Database
|
||||
*/
|
||||
template <> struct type_traits<rdb::Database> : public type_traits<void> {
|
||||
typedef tl::false_tag has_copy_constructor;
|
||||
typedef tl::false_tag has_default_constructor;
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -29,11 +29,12 @@
|
|||
|
||||
#include <iterator>
|
||||
#include <algorithm>
|
||||
#include <type_traits>
|
||||
|
||||
namespace tl
|
||||
{
|
||||
|
||||
template <class C, class CanCopy> class list_impl;
|
||||
template <class C, bool copy_constructible> class list_impl;
|
||||
|
||||
/**
|
||||
* @brief A base class for objects that can be kept in the linked list
|
||||
|
|
@ -109,7 +110,7 @@ private:
|
|||
};
|
||||
|
||||
template <class C>
|
||||
class list_impl<C, tl::false_tag>
|
||||
class list_impl<C, false>
|
||||
{
|
||||
public:
|
||||
list_impl () : m_head (), m_back ()
|
||||
|
|
@ -142,7 +143,7 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
void swap (list_impl<C, tl::false_tag> &other)
|
||||
void swap (list_impl<C, false> &other)
|
||||
{
|
||||
std::swap (m_head.mp_next, other.m_head.mp_next);
|
||||
if (m_head.mp_next) {
|
||||
|
|
@ -308,21 +309,21 @@ private:
|
|||
};
|
||||
|
||||
template <class C>
|
||||
class list_impl<C, tl::true_tag>
|
||||
: public list_impl<C, tl::false_tag>
|
||||
class list_impl<C, true>
|
||||
: public list_impl<C, false>
|
||||
{
|
||||
public:
|
||||
using list_impl<C, tl::false_tag>::insert;
|
||||
using list_impl<C, tl::false_tag>::push_back;
|
||||
using list_impl<C, tl::false_tag>::pop_back;
|
||||
using list_impl<C, tl::false_tag>::insert_before;
|
||||
using list_impl<C, tl::false_tag>::push_front;
|
||||
using list_impl<C, tl::false_tag>::pop_front;
|
||||
using list_impl<C, false>::insert;
|
||||
using list_impl<C, false>::push_back;
|
||||
using list_impl<C, false>::pop_back;
|
||||
using list_impl<C, false>::insert_before;
|
||||
using list_impl<C, false>::push_front;
|
||||
using list_impl<C, false>::pop_front;
|
||||
|
||||
list_impl () { }
|
||||
|
||||
list_impl (const list_impl &other)
|
||||
: list_impl<C, tl::false_tag> ()
|
||||
: list_impl<C, false> ()
|
||||
{
|
||||
operator= (other);
|
||||
}
|
||||
|
|
@ -330,7 +331,7 @@ public:
|
|||
list_impl &operator= (const list_impl &other)
|
||||
{
|
||||
if (this != &other) {
|
||||
list_impl<C, tl::false_tag>::clear ();
|
||||
list_impl<C, false>::clear ();
|
||||
for (const C *p = other.first (); p; p = p->next ()) {
|
||||
push_back (*p);
|
||||
}
|
||||
|
|
@ -444,7 +445,7 @@ private:
|
|||
*/
|
||||
template <class C>
|
||||
class list
|
||||
: public list_impl<C, typename tl::type_traits<C>::has_copy_constructor>
|
||||
: public list_impl<C, std::is_copy_constructible<C>::value>
|
||||
{
|
||||
public:
|
||||
typedef list_iterator<C> iterator;
|
||||
|
|
@ -454,17 +455,17 @@ public:
|
|||
|
||||
typedef C value_type;
|
||||
|
||||
using list_impl<C, typename tl::type_traits<C>::has_copy_constructor>::first;
|
||||
using list_impl<C, typename tl::type_traits<C>::has_copy_constructor>::last;
|
||||
using list_impl<C, typename tl::type_traits<C>::has_copy_constructor>::head;
|
||||
using list_impl<C, typename tl::type_traits<C>::has_copy_constructor>::back;
|
||||
using list_impl<C, std::is_copy_constructible<C>::value>::first;
|
||||
using list_impl<C, std::is_copy_constructible<C>::value>::last;
|
||||
using list_impl<C, std::is_copy_constructible<C>::value>::head;
|
||||
using list_impl<C, std::is_copy_constructible<C>::value>::back;
|
||||
|
||||
list () { }
|
||||
list (const list &other) : list_impl<C, typename tl::type_traits<C>::has_copy_constructor> (other) { }
|
||||
list (const list &other) : list_impl<C, std::is_copy_constructible<C>::value> (other) { }
|
||||
|
||||
list &operator= (const list &other)
|
||||
{
|
||||
list_impl<C, typename tl::type_traits<C>::has_copy_constructor>::operator= (other);
|
||||
list_impl<C, std::is_copy_constructible<C>::value>::operator= (other);
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -43,26 +43,6 @@ class RelativeProgress;
|
|||
class AbstractProgress;
|
||||
class AbsoluteProgress;
|
||||
|
||||
template <> struct type_traits<tl::Progress> : public type_traits<void> {
|
||||
typedef tl::false_tag has_copy_constructor;
|
||||
typedef tl::false_tag has_default_constructor;
|
||||
};
|
||||
|
||||
template <> struct type_traits<tl::RelativeProgress> : public type_traits<void> {
|
||||
typedef tl::false_tag has_copy_constructor;
|
||||
typedef tl::false_tag has_default_constructor;
|
||||
};
|
||||
|
||||
template <> struct type_traits<tl::AbstractProgress> : public type_traits<void> {
|
||||
typedef tl::false_tag has_copy_constructor;
|
||||
typedef tl::false_tag has_default_constructor;
|
||||
};
|
||||
|
||||
template <> struct type_traits<tl::AbsoluteProgress> : public type_traits<void> {
|
||||
typedef tl::false_tag has_copy_constructor;
|
||||
typedef tl::false_tag has_default_constructor;
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief A helper class to clean up pending progress objects
|
||||
*
|
||||
|
|
|
|||
|
|
@ -183,12 +183,6 @@ private:
|
|||
std::string m_description;
|
||||
};
|
||||
|
||||
template<> struct type_traits<tl::Recipe> : public type_traits<void>
|
||||
{
|
||||
typedef tl::false_tag has_copy_constructor;
|
||||
typedef tl::false_tag has_default_constructor;
|
||||
};
|
||||
|
||||
} // namespace tl
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -36,14 +36,14 @@
|
|||
namespace tl
|
||||
{
|
||||
|
||||
template <class Value> class reuse_vector;
|
||||
template <class Value> class reuse_vector_const_iterator;
|
||||
template <class Value, bool trivial_relocate> class reuse_vector;
|
||||
template <class Value, bool trivial_relocate> class reuse_vector_const_iterator;
|
||||
|
||||
/**
|
||||
* @brief The iterator for a reuse_vector
|
||||
*/
|
||||
|
||||
template <class Value>
|
||||
template <class Value, bool trivial_relocate>
|
||||
class reuse_vector_iterator
|
||||
{
|
||||
public:
|
||||
|
|
@ -64,14 +64,14 @@ public:
|
|||
/**
|
||||
* @brief The constructor
|
||||
*/
|
||||
reuse_vector_iterator (reuse_vector<Value> *v, size_type n)
|
||||
reuse_vector_iterator (reuse_vector<Value, trivial_relocate> *v, size_type n)
|
||||
: mp_v (v), m_n (n)
|
||||
{ }
|
||||
|
||||
/**
|
||||
* @brief Equality with const iterator
|
||||
*/
|
||||
bool operator== (const reuse_vector_const_iterator<Value> &d) const
|
||||
bool operator== (const reuse_vector_const_iterator<Value, trivial_relocate> &d) const
|
||||
{
|
||||
return mp_v == d.mp_v && m_n == d.m_n;
|
||||
}
|
||||
|
|
@ -79,7 +79,7 @@ public:
|
|||
/**
|
||||
* @brief Inequality with const iterator
|
||||
*/
|
||||
bool operator!= (const reuse_vector_const_iterator<Value> &d) const
|
||||
bool operator!= (const reuse_vector_const_iterator<Value, trivial_relocate> &d) const
|
||||
{
|
||||
return ! operator== (d);
|
||||
}
|
||||
|
|
@ -171,7 +171,7 @@ public:
|
|||
/**
|
||||
* @brief The pointer to the vector that this iterator points into
|
||||
*/
|
||||
reuse_vector<Value> *vector () const
|
||||
reuse_vector<Value, trivial_relocate> *vector () const
|
||||
{
|
||||
return mp_v;
|
||||
}
|
||||
|
|
@ -193,7 +193,7 @@ public:
|
|||
private:
|
||||
template <class V> friend class reuse_vector_const_iterator;
|
||||
|
||||
reuse_vector<Value> *mp_v;
|
||||
reuse_vector<Value, trivial_relocate> *mp_v;
|
||||
size_type m_n;
|
||||
};
|
||||
|
||||
|
|
@ -202,7 +202,7 @@ private:
|
|||
* @brief The const_iterator for a reuse_vector
|
||||
*/
|
||||
|
||||
template <class Value>
|
||||
template <class Value, bool trivial_relocate>
|
||||
class reuse_vector_const_iterator
|
||||
{
|
||||
public:
|
||||
|
|
@ -223,23 +223,23 @@ public:
|
|||
/**
|
||||
* @brief The constructor
|
||||
*/
|
||||
reuse_vector_const_iterator (const reuse_vector<Value> *v, size_type n)
|
||||
reuse_vector_const_iterator (const reuse_vector<Value, trivial_relocate> *v, size_type n)
|
||||
: mp_v (v), m_n (n)
|
||||
{ }
|
||||
|
||||
/**
|
||||
* @brief The conversion of a non-const iterator to a const iterator
|
||||
*/
|
||||
reuse_vector_const_iterator (const reuse_vector_iterator<Value> &d)
|
||||
reuse_vector_const_iterator (const reuse_vector_iterator<Value, trivial_relocate> &d)
|
||||
: mp_v (d.mp_v), m_n (d.m_n)
|
||||
{ }
|
||||
|
||||
/**
|
||||
* @brief cast to non-const iterator
|
||||
*/
|
||||
reuse_vector_iterator<Value> to_non_const () const
|
||||
reuse_vector_iterator<Value, trivial_relocate> to_non_const () const
|
||||
{
|
||||
return reuse_vector_iterator<Value> (const_cast<reuse_vector<Value> *> (mp_v), m_n);
|
||||
return reuse_vector_iterator<Value, trivial_relocate> (const_cast<reuse_vector<Value, trivial_relocate> *> (mp_v), m_n);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -340,7 +340,7 @@ public:
|
|||
/**
|
||||
* @brief The pointer to the vector that this iterator points into
|
||||
*/
|
||||
const reuse_vector<Value> *vector () const
|
||||
const reuse_vector<Value, trivial_relocate> *vector () const
|
||||
{
|
||||
return mp_v;
|
||||
}
|
||||
|
|
@ -362,7 +362,7 @@ public:
|
|||
private:
|
||||
template <class V> friend class reuse_vector_iterator;
|
||||
|
||||
const reuse_vector<Value> *mp_v;
|
||||
const reuse_vector<Value, trivial_relocate> *mp_v;
|
||||
size_type m_n;
|
||||
};
|
||||
|
||||
|
|
@ -491,14 +491,14 @@ private:
|
|||
* One requirement is that sizeof(C) >= sizeof(void *).
|
||||
*/
|
||||
|
||||
template <class Value>
|
||||
template <class Value, bool trivial_relocate = std::is_trivially_copy_constructible<Value>::value>
|
||||
class reuse_vector
|
||||
{
|
||||
public:
|
||||
typedef Value value_type;
|
||||
typedef size_t size_type;
|
||||
typedef reuse_vector_iterator<value_type> iterator;
|
||||
typedef reuse_vector_const_iterator<value_type> const_iterator;
|
||||
typedef reuse_vector_iterator<value_type, trivial_relocate> iterator;
|
||||
typedef reuse_vector_const_iterator<value_type, trivial_relocate> const_iterator;
|
||||
|
||||
/**
|
||||
* @brief Default constructor
|
||||
|
|
@ -889,8 +889,11 @@ public:
|
|||
*/
|
||||
void reserve (size_type n)
|
||||
{
|
||||
typename tl::type_traits<Value>::relocate_requirements relocate_requirements_tag;
|
||||
internal_reserve (n, relocate_requirements_tag);
|
||||
if (trivial_relocate) {
|
||||
internal_reserve_trivial (n);
|
||||
} else {
|
||||
internal_reserve_complex (n);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -979,7 +982,7 @@ private:
|
|||
}
|
||||
}
|
||||
|
||||
void internal_reserve (size_type n, tl::complex_relocate_required)
|
||||
void internal_reserve_complex (size_type n)
|
||||
{
|
||||
if (n > capacity ()) {
|
||||
|
||||
|
|
@ -1010,7 +1013,7 @@ private:
|
|||
}
|
||||
}
|
||||
|
||||
void internal_reserve (size_type n, tl::trivial_relocate_required)
|
||||
void internal_reserve_trivial (size_type n)
|
||||
{
|
||||
if (n > capacity ()) {
|
||||
|
||||
|
|
|
|||
|
|
@ -41,6 +41,21 @@ namespace tl
|
|||
|
||||
static std::locale c_locale ("C");
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// Exception classes
|
||||
|
||||
ExtractorNotImplementedException::ExtractorNotImplementedException ()
|
||||
: Exception (tl::to_string (tr ("No string extractor available")))
|
||||
{
|
||||
// .. nothing yet ..
|
||||
}
|
||||
|
||||
StringConversionException::StringConversionException ()
|
||||
: Exception (tl::to_string (tr ("No string conversion available")))
|
||||
{
|
||||
// .. nothing yet ..
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// lower and upper case for wchar_t and uint32_t
|
||||
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@
|
|||
|
||||
#include "tlException.h"
|
||||
#include "tlVariant.h"
|
||||
#include "tlTypeTraits.h"
|
||||
|
||||
#if defined(HAVE_QT)
|
||||
class QImage;
|
||||
|
|
@ -40,9 +41,29 @@ class QImage;
|
|||
|
||||
namespace tl {
|
||||
|
||||
/**
|
||||
* @brief An exception indicating that string extraction is not available for a certain type
|
||||
*/
|
||||
class ExtractorNotImplementedException
|
||||
: tl::Exception
|
||||
{
|
||||
public:
|
||||
ExtractorNotImplementedException ();
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief An exception indicating that string conversion is not available for a certain type
|
||||
*/
|
||||
class StringConversionException
|
||||
: tl::Exception
|
||||
{
|
||||
public:
|
||||
StringConversionException ();
|
||||
};
|
||||
|
||||
class Extractor;
|
||||
template <class T> void extractor_impl (tl::Extractor &, T &);
|
||||
template <class T> bool test_extractor_impl (tl::Extractor &, T &);
|
||||
template <class T> void extractor_impl (tl::Extractor &, T &) { throw ExtractorNotImplementedException (); }
|
||||
template <class T> bool test_extractor_impl (tl::Extractor &, T &) { throw ExtractorNotImplementedException (); }
|
||||
|
||||
/**
|
||||
* @brief Another string class
|
||||
|
|
@ -266,7 +287,11 @@ TL_PUBLIC std::string to_string (const char *cp, int length);
|
|||
TL_PUBLIC std::string to_string_from_local (const char *cp);
|
||||
TL_PUBLIC std::string to_local (const std::string &s);
|
||||
|
||||
template <class T> inline std::string to_string (const T &o) { return o.to_string (); }
|
||||
template <class T, bool> struct __redirect_to_string;
|
||||
template <class T> struct __redirect_to_string<T, true> { static std::string to_string (const T &t) { return t.to_string (); } };
|
||||
template <class T> struct __redirect_to_string<T, false> { static std::string to_string (const T &) { throw StringConversionException (); } };
|
||||
template <class T> inline std::string to_string (const T &o) { return __redirect_to_string<T, tl::has_to_string<T>::value>::to_string (o); }
|
||||
|
||||
template <> inline std::string to_string (const double &d) { return to_string (d, 12); }
|
||||
template <> inline std::string to_string (const float &d) { return to_string (d, 6); }
|
||||
template <> TL_PUBLIC std::string to_string (const int &d);
|
||||
|
|
|
|||
|
|
@ -67,50 +67,56 @@ inline bool value_of (true_tag) { return true; }
|
|||
*/
|
||||
inline bool value_of (false_tag) { return false; }
|
||||
|
||||
/**
|
||||
* @brief A tag class which defines a object to require complex relocation.
|
||||
*/
|
||||
struct complex_relocate_required { };
|
||||
// SFINAE boolean types
|
||||
typedef char __yes_type [1];
|
||||
typedef char __no_type [2];
|
||||
|
||||
/**
|
||||
* @brief A tag class which defines a object to allow trivial relocation.
|
||||
* @brief Detects whether a class has a "to_string" method with a matching signature
|
||||
*/
|
||||
struct trivial_relocate_required { };
|
||||
template <typename T> static __yes_type &__test_to_string_func (decltype (&T::to_string));
|
||||
template <typename> static __no_type &__test_to_string_func (...);
|
||||
|
||||
/**
|
||||
* @brief The type traits struct that defines some requirements for the given type T
|
||||
*
|
||||
* Specifically the following typedefs must be provided:
|
||||
*
|
||||
* "relocate_requirements" specifies how the object needs to be relocated.
|
||||
* This typdef can be complex_relocate_required or trivial_relocate_required.
|
||||
* Complex relocation is implemented by a copy construction and destruction of the
|
||||
* source object. Trivial relocation is implemented by a memcpy.
|
||||
* The default is complex relocation.
|
||||
*
|
||||
* "has_copy_constructor" specifies if a class has a copy constructor.
|
||||
* This typedef can be true_tag or false_tag. The default is "true_tag".
|
||||
*
|
||||
* "has_default_constructor" specifies if a class has a default constructor.
|
||||
* This typedef can be true_tag or false_tag. The default is "true_tag".
|
||||
*
|
||||
* "has_efficient_swap" specifies that it is beneficial to use std::swap
|
||||
* on those objects because it is implemented very efficiently. The default is "false_tag".
|
||||
*
|
||||
* TODO: further requirements shall go here.
|
||||
*/
|
||||
template <class T>
|
||||
struct type_traits
|
||||
template <typename T>
|
||||
struct has_to_string
|
||||
{
|
||||
typedef complex_relocate_required relocate_requirements;
|
||||
typedef true_tag has_copy_constructor;
|
||||
typedef true_tag has_default_constructor;
|
||||
typedef true_tag has_public_destructor;
|
||||
typedef false_tag has_efficient_swap;
|
||||
typedef false_tag supports_extractor;
|
||||
typedef false_tag supports_to_string;
|
||||
typedef false_tag has_less_operator;
|
||||
typedef false_tag has_equal_operator;
|
||||
static constexpr bool value = sizeof (__test_to_string_func<T> (nullptr)) == sizeof (__yes_type);
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Detects whether a class has an equal operator
|
||||
*/
|
||||
template <typename T> static __yes_type &__test_equal_func (decltype (&T::operator==));
|
||||
template <typename> static __no_type &__test_equal_func (...);
|
||||
|
||||
template <typename T>
|
||||
struct has_equal_operator
|
||||
{
|
||||
static constexpr bool value = sizeof (__test_equal_func<T> (nullptr)) == sizeof (__yes_type);
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Detects whether a class has a less operator
|
||||
*/
|
||||
template <typename T> static __yes_type &__test_less_func (decltype (&T::operator==));
|
||||
template <typename> static __no_type &__test_less_func (...);
|
||||
|
||||
template <typename T>
|
||||
struct has_less_operator
|
||||
{
|
||||
static constexpr bool value = sizeof (__test_less_func<T> (nullptr)) == sizeof (__yes_type);
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief Detects whether a class has a "swap" method with a matching signature
|
||||
*/
|
||||
template <typename T> static __yes_type &__test_swap_func (decltype (&T::swap));
|
||||
template <typename> static __no_type &__test_swap_func (...);
|
||||
|
||||
template <typename T>
|
||||
struct has_swap
|
||||
{
|
||||
static constexpr bool value = sizeof (__test_swap_func<T> (nullptr)) == sizeof (__yes_type);
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,113 +34,90 @@ namespace tl
|
|||
|
||||
class EvalClass;
|
||||
|
||||
/**
|
||||
* @brief A helper function to implement equal as efficiently as possible
|
||||
*/
|
||||
template<class T, class I>
|
||||
bool _var_user_equal_impl (const T *a, const T *b, I);
|
||||
|
||||
template<class T>
|
||||
bool _var_user_equal_impl (const T *a, const T *b, tl::true_tag)
|
||||
{
|
||||
return *a == *b;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
bool _var_user_equal_impl (const T * /*a*/, const T * /*b*/, tl::false_tag)
|
||||
{
|
||||
tl_assert (false);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief A helper function to implement clone as efficiently as possible
|
||||
*/
|
||||
template<class T, class I>
|
||||
T *_var_user_clone_impl (const T *a, I);
|
||||
template<class T, bool> struct _var_user_clone_impl;
|
||||
|
||||
template<class T>
|
||||
T *_var_user_clone_impl (const T *a, tl::true_tag)
|
||||
struct _var_user_clone_impl<T, true>
|
||||
{
|
||||
return new T (*a);
|
||||
}
|
||||
static T *call (const T *a) { new T (*a); }
|
||||
};
|
||||
|
||||
template<class T>
|
||||
T *_var_user_clone_impl (const T * /*a*/, tl::false_tag)
|
||||
struct _var_user_clone_impl<T, false>
|
||||
{
|
||||
tl_assert (false);
|
||||
}
|
||||
static T *call (const T *) { tl_assert (false); }
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief A helper function to implement assignment as efficiently as possible
|
||||
* @brief A helper function to implement assign as efficiently as possible
|
||||
*/
|
||||
template<class T, class I>
|
||||
void _var_user_assign_impl (T *a, const T *b, I);
|
||||
template<class T, bool> struct _var_user_assign_impl;
|
||||
|
||||
template<class T>
|
||||
void _var_user_assign_impl (T *a, const T *b, tl::true_tag)
|
||||
struct _var_user_assign_impl<T, true>
|
||||
{
|
||||
*a = *b;
|
||||
}
|
||||
static void call (T *a, const T *b) { *a = *b; }
|
||||
};
|
||||
|
||||
template<class T>
|
||||
void _var_user_assign_impl (T * /*a*/, const T * /*b*/, tl::false_tag)
|
||||
struct _var_user_assign_impl<T, false>
|
||||
{
|
||||
tl_assert (false);
|
||||
}
|
||||
static void call (T *, const T *) { tl_assert (false); }
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief A helper function to implement less as efficiently as possible
|
||||
* @brief A helper function to implement equal as efficiently as possible
|
||||
*/
|
||||
template<class T, class I>
|
||||
bool _var_user_less_impl (const T *a, const T *b, I);
|
||||
template<class T, bool> struct _var_user_equal_impl;
|
||||
|
||||
template<class T>
|
||||
bool _var_user_less_impl (const T *a, const T *b, tl::true_tag)
|
||||
struct _var_user_equal_impl<T, true>
|
||||
{
|
||||
return *a < *b;
|
||||
}
|
||||
static bool call (const T *a, const T *b) { return *a == *b; }
|
||||
};
|
||||
|
||||
template<class T>
|
||||
bool _var_user_less_impl (const T *, const T *, tl::false_tag)
|
||||
struct _var_user_equal_impl<T, false>
|
||||
{
|
||||
tl_assert (false);
|
||||
}
|
||||
static bool call (const T *, const T *) { tl_assert (false); }
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief A helper function to implement to_string as efficiently as possible
|
||||
* @brief A helper function to implement equal as efficiently as possible
|
||||
*/
|
||||
template<class T, class I>
|
||||
std::string _var_user_to_string_impl (const T *a, I);
|
||||
template<class T, bool> struct _var_user_less_impl;
|
||||
|
||||
template<class T>
|
||||
std::string _var_user_to_string_impl (const T *a, tl::true_tag)
|
||||
struct _var_user_less_impl<T, true>
|
||||
{
|
||||
return a->to_string ();
|
||||
}
|
||||
static bool call (const T *a, const T *b) { return *a < *b; }
|
||||
};
|
||||
|
||||
template<class T>
|
||||
std::string _var_user_to_string_impl (const T *, tl::false_tag)
|
||||
struct _var_user_less_impl<T, false>
|
||||
{
|
||||
tl_assert (false);
|
||||
}
|
||||
static bool call (const T *, const T *) { tl_assert (false); }
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief A helper function to implement read as efficiently as possible
|
||||
* @brief A helper function to implement equal as efficiently as possible
|
||||
*/
|
||||
template<class T, class I>
|
||||
void _var_user_read_impl (T *a, tl::Extractor &ex, I);
|
||||
template<class T, bool> struct _var_user_to_string_impl;
|
||||
|
||||
template<class T>
|
||||
void _var_user_read_impl (T *a, tl::Extractor &ex, tl::true_tag)
|
||||
struct _var_user_to_string_impl<T, true>
|
||||
{
|
||||
ex.read (*a);
|
||||
}
|
||||
static std::string call (const T *a) { return a->to_string (); }
|
||||
};
|
||||
|
||||
template<class T>
|
||||
void _var_user_read_impl (T *, tl::Extractor &, tl::false_tag)
|
||||
struct _var_user_to_string_impl<T, false>
|
||||
{
|
||||
tl_assert (false);
|
||||
}
|
||||
static std::string call (const T *) { tl_assert (false); }
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief A utility implementation of tl::VariantUserClass using type traits for the implementation
|
||||
|
|
@ -162,39 +139,32 @@ public:
|
|||
|
||||
virtual bool equal (const void *a, const void *b) const
|
||||
{
|
||||
typename tl::type_traits<T>::has_equal_operator f;
|
||||
return _var_user_equal_impl ((T *) a, (T *) b, f);
|
||||
return _var_user_equal_impl<T, tl::has_equal_operator<T>::value> ((const T *) a, (const T *) b);
|
||||
}
|
||||
|
||||
virtual bool less (const void *a, const void *b) const
|
||||
{
|
||||
typename tl::type_traits<T>::has_less_operator f;
|
||||
return _var_user_less_impl ((T *) a, (T *) b, f);
|
||||
return _var_user_less_impl<T, tl::has_less_operator<T>::value> ((const T *) a, (const T *) b);
|
||||
}
|
||||
|
||||
virtual void *clone (const void *a) const
|
||||
{
|
||||
typename tl::type_traits<T>::has_copy_constructor f;
|
||||
return _var_user_clone_impl ((const T *) a, f);
|
||||
return _var_user_clone_impl<T, std::is_copy_constructible<T>::value> ((const T *) a);
|
||||
}
|
||||
|
||||
virtual void assign (void *a, const void *b) const
|
||||
{
|
||||
// TODO: we assume (for now) that objects with a copy constructor do have an assignment operator too
|
||||
typename tl::type_traits<T>::has_copy_constructor f;
|
||||
_var_user_assign_impl ((T *) a, (const T *) b, f);
|
||||
_var_user_assign_impl<T, std::is_copy_assignable<T>::value> ((T *) a, (const T *)b);
|
||||
}
|
||||
|
||||
virtual std::string to_string (const void *a) const
|
||||
{
|
||||
typename tl::type_traits<T>::supports_to_string f;
|
||||
return _var_user_to_string_impl ((const T *) a, f);
|
||||
return _var_user_to_string_impl<T, tl::has_to_string<T>::value> ((const T *) a);
|
||||
}
|
||||
|
||||
virtual void read (void *a, tl::Extractor &ex) const
|
||||
{
|
||||
typename tl::type_traits<T>::supports_extractor f;
|
||||
_var_user_read_impl ((T *) a, ex, f);
|
||||
ex.read (*(T *)a);
|
||||
}
|
||||
|
||||
virtual const char *name () const
|
||||
|
|
|
|||
|
|
@ -93,26 +93,6 @@ public:
|
|||
vector (const T &v, int s) : base (v, s) { }
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief The type traits for the vector type
|
||||
*/
|
||||
template <class C>
|
||||
struct type_traits <tl::vector<C> > : public type_traits<void>
|
||||
{
|
||||
#if defined(_ITERATOR_DEBUG_LEVEL) && _ITERATOR_DEBUG_LEVEL != 0
|
||||
// With iterator debugging on, the vector carries additional
|
||||
// information which cannot be copied trivially
|
||||
typedef complex_relocate_required relocate_requirements;
|
||||
#else
|
||||
typedef trivial_relocate_required relocate_requirements;
|
||||
#endif
|
||||
typedef true_tag has_efficient_swap;
|
||||
typedef false_tag supports_extractor;
|
||||
typedef false_tag supports_to_string;
|
||||
typedef true_tag has_less_operator;
|
||||
typedef true_tag has_equal_operator;
|
||||
};
|
||||
|
||||
} // namespace tl
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -569,25 +569,6 @@ EdgeClassClass::execute (const tl::ExpressionParserContext &context, tl::Variant
|
|||
}
|
||||
}
|
||||
|
||||
namespace tl
|
||||
{
|
||||
|
||||
template <>
|
||||
struct type_traits <Box> : public type_traits<void>
|
||||
{
|
||||
typedef trivial_relocate_required relocate_requirements;
|
||||
typedef true_tag supports_to_string;
|
||||
};
|
||||
|
||||
template <>
|
||||
struct type_traits <Edge> : public type_traits<void>
|
||||
{
|
||||
typedef trivial_relocate_required relocate_requirements;
|
||||
typedef true_tag supports_to_string;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
// basics: custom objects
|
||||
TEST(1b)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -53,15 +53,6 @@ public:
|
|||
|
||||
}
|
||||
|
||||
namespace tl
|
||||
{
|
||||
template <>
|
||||
struct type_traits<MyClass2> : public tl::type_traits<void>
|
||||
{
|
||||
typedef tl::false_tag has_copy_constructor;
|
||||
};
|
||||
}
|
||||
|
||||
template <class C>
|
||||
static std::string l2s (const tl::list<C> &l)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -210,13 +210,6 @@ int A::dc = 0;
|
|||
|
||||
}
|
||||
|
||||
namespace tl
|
||||
{
|
||||
template <> struct type_traits<A> : public type_traits<void> {
|
||||
typedef trivial_relocate_required relocate_requirements;
|
||||
};
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
class B {
|
||||
|
|
@ -238,18 +231,11 @@ int B::dc = 0;
|
|||
|
||||
}
|
||||
|
||||
namespace tl
|
||||
{
|
||||
template <> struct type_traits<B> : public type_traits<void> {
|
||||
typedef complex_relocate_required relocate_requirements;
|
||||
};
|
||||
}
|
||||
|
||||
// Test: relocate strategy
|
||||
TEST(4)
|
||||
{
|
||||
tl::reuse_vector<A> va;
|
||||
tl::reuse_vector<B> vb;
|
||||
tl::reuse_vector<A, true> va;
|
||||
tl::reuse_vector<B, false> vb;
|
||||
A::reset ();
|
||||
B::reset ();
|
||||
|
||||
|
|
@ -259,11 +245,11 @@ TEST(4)
|
|||
}
|
||||
|
||||
int i = 0;
|
||||
for (tl::reuse_vector<A>::const_iterator n = va.begin (); n != va.end (); ++n, ++i) {
|
||||
for (tl::reuse_vector<A, true>::const_iterator n = va.begin (); n != va.end (); ++n, ++i) {
|
||||
EXPECT_EQ (n->x, 100 - i * 10);
|
||||
}
|
||||
i = 0;
|
||||
for (tl::reuse_vector<B>::const_iterator n = vb.begin (); n != vb.end (); ++n, ++i) {
|
||||
for (tl::reuse_vector<B, false>::const_iterator n = vb.begin (); n != vb.end (); ++n, ++i) {
|
||||
EXPECT_EQ (n->x, 100 - i * 10);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -48,18 +48,6 @@ struct AA
|
|||
|
||||
int AA::ac = 0;
|
||||
|
||||
namespace tl
|
||||
{
|
||||
template<>
|
||||
class type_traits<A>
|
||||
: public type_traits<void>
|
||||
{
|
||||
public:
|
||||
typedef tl::true_tag supports_to_string;
|
||||
typedef tl::true_tag has_copy_constructor;
|
||||
};
|
||||
}
|
||||
|
||||
struct B
|
||||
{
|
||||
int bb;
|
||||
|
|
@ -69,20 +57,6 @@ struct B
|
|||
const std::string &to_string () const { return b; }
|
||||
};
|
||||
|
||||
namespace tl
|
||||
{
|
||||
template<>
|
||||
class type_traits<B>
|
||||
: public type_traits<void>
|
||||
{
|
||||
public:
|
||||
typedef tl::true_tag supports_to_string;
|
||||
typedef tl::true_tag has_equal_operator;
|
||||
typedef tl::true_tag has_less_operator;
|
||||
typedef tl::true_tag has_copy_constructor;
|
||||
};
|
||||
}
|
||||
|
||||
static tl::VariantUserClassImpl<A> a_class_instance;
|
||||
static tl::VariantUserClassImpl<AA> aa_class_instance;
|
||||
static tl::VariantUserClassImpl<B> b_class_instance;
|
||||
|
|
|
|||
Loading…
Reference in New Issue