diff orange/util/Traits.d @ 0:f7b078e85f7f

First commit
author Jacob Carlborg <doob@me.com>
date Wed, 26 May 2010 17:19:13 +0200
parents
children 11a31bd929f9
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/orange/util/Traits.d	Wed May 26 17:19:13 2010 +0200
@@ -0,0 +1,46 @@
+/**
+ * Copyright: Copyright (c) 2010 Jacob Carlborg.
+ * Authors: Jacob Carlborg
+ * Version: Initial created: Jan 26, 2010
+ * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost Software License 1.0)
+ */
+module orange.util.Traits;
+
+public import mambo.util.Traits;
+
+import orange.serialization.Serializable;
+import orange.serialization.archives.Archive;
+import orange.util._;
+
+template isArchive (T)
+{
+	const isArchive = is(typeof({
+		alias T.DataType Foo;
+	})) &&
+
+	is(typeof(T.archive(0, TypeOfDataType!(T).init, {}))) &&
+	is(typeof(T.unarchive!(int))) && 
+	is(typeof(T.beginArchiving)) &&
+	is(typeof(T.beginUnarchiving(TypeOfDataType!(T).init))) &&
+	is(typeof(T.archiveBaseClass!(Object))) &&
+	is(typeof(T.unarchiveBaseClass!(Object))) &&
+	is(typeof(T.reset)) &&
+	is(typeof({TypeOfDataType!(T) a = T.data;})) &&
+	is(typeof(T.unarchiveAssociativeArrayVisitor!(int[string])));
+	
+}
+
+template isSerializable (T, ArchiveType)
+{
+	const isSerializable = is(typeof(T.toData(ArchiveType.init, ArchiveType.DataType.init))) && is(typeof(T.fromData(ArchiveType.init, ArchiveType.DataType.init)));
+}
+
+template isISerializable (T)
+{
+	const isISerializable = is(T : ISerializable);
+}
+
+template TypeOfDataType (T)
+{
+	alias T.DataType TypeOfDataType;
+}
\ No newline at end of file