Bläddra i källkod

Initial commit of datamodel. Contains preprocessor generators to transform Object-Oriented structures into Data-Oriented element vectors.

Samuel Jaffe 9 år sedan
incheckning
3c2764000a

+ 75 - 0
Makefile

@@ -0,0 +1,75 @@
+WARNINGS := -Wall -pedantic  -pedantic-errors -Wextra -Wcast-align \
+  -Wcast-qual  -Wchar-subscripts  -Wcomment -Wconversion \
+  -Wdisabled-optimization -Werror -Wfloat-equal  -Wformat  -Wformat=2 \
+  -Wformat-nonliteral -Wformat-security  -Wformat-y2k \
+  -Wimport  -Winit-self  -Winline -Winvalid-pch   \
+  -Wunsafe-loop-optimizations  -Wno-long-long -Wmissing-braces \
+  -Wmissing-field-initializers -Wmissing-format-attribute   \
+  -Wmissing-include-dirs -Wmissing-noreturn -Wmissing-declarations \
+  -Wpacked -Wparentheses  -Wpointer-arith \
+  -Wredundant-decls -Wreturn-type \
+  -Wsequence-point  -Wshadow -Wsign-compare  -Wstack-protector \
+  -Wstrict-aliasing -Wstrict-aliasing=2 -Wswitch  -Wswitch-default \
+  -Wswitch-enum -Wtrigraphs  -Wuninitialized \
+  -Wunknown-pragmas  -Wunreachable-code -Wunused \
+  -Wunused-function  -Wunused-label  -Wunused-parameter \
+  -Wunused-value  -Wunused-variable  -Wvariadic-macros \
+  -Wvolatile-register-var  -Wwrite-strings
+
+CWARNINGS := $(WARNINGS) -Wimplicit
+CPPWARNINGS := $(WARNINGS)
+
+CFLAGS   := $(CWARNINGS)
+CPPFLAGS := $(CPPWARNINGS) --std=c++11
+LDFLAGS  :=
+
+HDRFILES := rotate.hpp
+SRCFILES := 
+TSTSUITE := rotate_tc.h
+
+BINARY   :=
+
+DEPFILES := $(patsubst %.cpp,.%.d,$(SRCFILES))
+OBJFILES := $(patsubst %.cpp,%.o,$(SRCFILES))
+TSTFILES := $(patsubst %.h,%.cpp,$(TSTSUITE))
+TSTDRIVR := $(patsubst %.cpp,%,$(TSTFILES))
+
+ALLFILES := $(SRCFILES) $(HDRFILES) $(AUXFILES)
+
+.PHONY: all clean debug release check coverage
+
+all: $(BINARY) $(LNBINARY)
+
+debug: CFLAGS += -DDEBUG -g
+debug: CPPFLAGS += -DDEBUG -g
+debug: all
+
+release: CFLAGS += -O2
+release: CPPFLAGS += -O2
+release: all
+
+coverage: CFLAGS += -fprofile-arcs -ftest-coverage
+coverage: CPPFLAGS += -fprofile-arcs -ftest-coverage
+coverage: check
+
+clean: check-clean
+	@$(RM) $(BINARY) $(wildcard $(OBJFILES)) $(LNBINARY)
+
+check-clean:
+	@$(RM) $(TSTDRIVR) $(TSTFILES)
+
+check: check-clean $(TSTDRIVR)
+
+.h.cpp:
+	@cxxtestgen --error-printer $< -o $@
+
+.cpp.o: Makefile
+	$(CXX) $(CPPFLAGS) -MMD -MP -MF $(patsubst %.cpp,.%.d,$<) -c $< -o $@
+
+$(BINARY): $(OBJFILES) 
+	$(CXX) $(LDFLAGS) -o $@ $(OBJFILES)
+
+$(TSTDRIVR): $(TSTFILES)
+	@$(CXX) $(CPPFLAGS) -I$(CXXTEST) -w $@.cpp -o $@
+	@echo Running TestDriver: ./$@
+	@./$@

+ 142 - 0
datamodel.xcodeproj/project.pbxproj

@@ -0,0 +1,142 @@
+// !$*UTF8*$!
+{
+	archiveVersion = 1;
+	classes = {
+	};
+	objectVersion = 46;
+	objects = {
+
+/* Begin PBXFileReference section */
+		0E9E98B11BBC8A02004FFE25 /* Makefile */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.make; path = Makefile; sourceTree = "<group>"; };
+		0E9E98B21BBC8A03004FFE25 /* rotate.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = rotate.hpp; sourceTree = "<group>"; };
+		0E9E98B61BBC8A35004FFE25 /* rotate_tc.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = rotate_tc.h; sourceTree = "<group>"; };
+		0E9E98B71BBC8DB8004FFE25 /* rotate_tc.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = rotate_tc.cpp; sourceTree = "<group>"; };
+/* End PBXFileReference section */
+
+/* Begin PBXGroup section */
+		0E9E98AB1BBC8A02004FFE25 = {
+			isa = PBXGroup;
+			children = (
+				0E9E98B11BBC8A02004FFE25 /* Makefile */,
+				0E9E98B21BBC8A03004FFE25 /* rotate.hpp */,
+				0E9E98B61BBC8A35004FFE25 /* rotate_tc.h */,
+				0E9E98B71BBC8DB8004FFE25 /* rotate_tc.cpp */,
+			);
+			sourceTree = "<group>";
+		};
+/* End PBXGroup section */
+
+/* Begin PBXLegacyTarget section */
+		0E9E98B01BBC8A02004FFE25 /* datamodel */ = {
+			isa = PBXLegacyTarget;
+			buildArgumentsString = "$(ACTION)";
+			buildConfigurationList = 0E9E98B31BBC8A03004FFE25 /* Build configuration list for PBXLegacyTarget "datamodel" */;
+			buildPhases = (
+			);
+			buildToolPath = /usr/bin/make;
+			buildWorkingDirectory = "/Users/leumasjaffe/Documents/Programming/XTools Workspace/C:C++/misc/datamodel";
+			dependencies = (
+			);
+			name = datamodel;
+			passBuildSettingsInEnvironment = 1;
+			productName = datamodel;
+		};
+/* End PBXLegacyTarget section */
+
+/* Begin PBXProject section */
+		0E9E98AC1BBC8A02004FFE25 /* Project object */ = {
+			isa = PBXProject;
+			attributes = {
+			};
+			buildConfigurationList = 0E9E98AF1BBC8A02004FFE25 /* Build configuration list for PBXProject "datamodel" */;
+			compatibilityVersion = "Xcode 3.2";
+			developmentRegion = English;
+			hasScannedForEncodings = 0;
+			knownRegions = (
+				en,
+			);
+			mainGroup = 0E9E98AB1BBC8A02004FFE25;
+			projectDirPath = "";
+			projectRoot = "";
+			targets = (
+				0E9E98B01BBC8A02004FFE25 /* datamodel */,
+			);
+		};
+/* End PBXProject section */
+
+/* Begin XCBuildConfiguration section */
+		0E9E98AD1BBC8A02004FFE25 /* Debug */ = {
+			isa = XCBuildConfiguration;
+			buildSettings = {
+				ARCHS = "$(ARCHS_STANDARD_32_BIT)";
+				COPY_PHASE_STRIP = NO;
+				GCC_WARN_ABOUT_RETURN_TYPE = YES;
+				GCC_WARN_UNUSED_VARIABLE = YES;
+				ONLY_ACTIVE_ARCH = YES;
+				SDKROOT = macosx10.6;
+			};
+			name = Debug;
+		};
+		0E9E98AE1BBC8A02004FFE25 /* Release */ = {
+			isa = XCBuildConfiguration;
+			buildSettings = {
+				ARCHS = "$(ARCHS_STANDARD_32_BIT)";
+				COPY_PHASE_STRIP = YES;
+				GCC_WARN_ABOUT_RETURN_TYPE = YES;
+				GCC_WARN_UNUSED_VARIABLE = YES;
+				SDKROOT = macosx10.6;
+			};
+			name = Release;
+		};
+		0E9E98B41BBC8A03004FFE25 /* Debug */ = {
+			isa = XCBuildConfiguration;
+			buildSettings = {
+				COPY_PHASE_STRIP = NO;
+				DEBUGGING_SYMBOLS = YES;
+				GCC_DYNAMIC_NO_PIC = NO;
+				GCC_ENABLE_FIX_AND_CONTINUE = YES;
+				GCC_GENERATE_DEBUGGING_SYMBOLS = YES;
+				GCC_OPTIMIZATION_LEVEL = 0;
+				OTHER_CFLAGS = "";
+				OTHER_LDFLAGS = "";
+				PRODUCT_NAME = datamodel;
+			};
+			name = Debug;
+		};
+		0E9E98B51BBC8A03004FFE25 /* Release */ = {
+			isa = XCBuildConfiguration;
+			buildSettings = {
+				COPY_PHASE_STRIP = YES;
+				DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
+				GCC_ENABLE_FIX_AND_CONTINUE = NO;
+				OTHER_CFLAGS = "";
+				OTHER_LDFLAGS = "";
+				PRODUCT_NAME = datamodel;
+			};
+			name = Release;
+		};
+/* End XCBuildConfiguration section */
+
+/* Begin XCConfigurationList section */
+		0E9E98AF1BBC8A02004FFE25 /* Build configuration list for PBXProject "datamodel" */ = {
+			isa = XCConfigurationList;
+			buildConfigurations = (
+				0E9E98AD1BBC8A02004FFE25 /* Debug */,
+				0E9E98AE1BBC8A02004FFE25 /* Release */,
+			);
+			defaultConfigurationIsVisible = 0;
+			defaultConfigurationName = Release;
+		};
+		0E9E98B31BBC8A03004FFE25 /* Build configuration list for PBXLegacyTarget "datamodel" */ = {
+			isa = XCConfigurationList;
+			buildConfigurations = (
+				0E9E98B41BBC8A03004FFE25 /* Debug */,
+				0E9E98B51BBC8A03004FFE25 /* Release */,
+			);
+			defaultConfigurationIsVisible = 0;
+			defaultConfigurationName = Release;
+		};
+/* End XCConfigurationList section */
+	};
+	rootObject = 0E9E98AC1BBC8A02004FFE25 /* Project object */;
+}

+ 80 - 0
datamodel.xcodeproj/xcuserdata/leumasjaffe.xcuserdatad/xcschemes/datamodel.xcscheme

@@ -0,0 +1,80 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Scheme
+   LastUpgradeVersion = "0700"
+   version = "1.3">
+   <BuildAction
+      parallelizeBuildables = "YES"
+      buildImplicitDependencies = "YES">
+      <BuildActionEntries>
+         <BuildActionEntry
+            buildForTesting = "YES"
+            buildForRunning = "YES"
+            buildForProfiling = "YES"
+            buildForArchiving = "YES"
+            buildForAnalyzing = "YES">
+            <BuildableReference
+               BuildableIdentifier = "primary"
+               BlueprintIdentifier = "0E9E98B01BBC8A02004FFE25"
+               BuildableName = "datamodel"
+               BlueprintName = "datamodel"
+               ReferencedContainer = "container:datamodel.xcodeproj">
+            </BuildableReference>
+         </BuildActionEntry>
+      </BuildActionEntries>
+   </BuildAction>
+   <TestAction
+      buildConfiguration = "Debug"
+      selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
+      selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
+      shouldUseLaunchSchemeArgsEnv = "YES">
+      <Testables>
+      </Testables>
+      <AdditionalOptions>
+      </AdditionalOptions>
+   </TestAction>
+   <LaunchAction
+      buildConfiguration = "Debug"
+      selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
+      selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
+      launchStyle = "0"
+      useCustomWorkingDirectory = "NO"
+      ignoresPersistentStateOnLaunch = "NO"
+      debugDocumentVersioning = "YES"
+      debugServiceExtension = "internal"
+      allowLocationSimulation = "YES">
+      <MacroExpansion>
+         <BuildableReference
+            BuildableIdentifier = "primary"
+            BlueprintIdentifier = "0E9E98B01BBC8A02004FFE25"
+            BuildableName = "datamodel"
+            BlueprintName = "datamodel"
+            ReferencedContainer = "container:datamodel.xcodeproj">
+         </BuildableReference>
+      </MacroExpansion>
+      <AdditionalOptions>
+      </AdditionalOptions>
+   </LaunchAction>
+   <ProfileAction
+      buildConfiguration = "Release"
+      shouldUseLaunchSchemeArgsEnv = "YES"
+      savedToolIdentifier = ""
+      useCustomWorkingDirectory = "NO"
+      debugDocumentVersioning = "YES">
+      <MacroExpansion>
+         <BuildableReference
+            BuildableIdentifier = "primary"
+            BlueprintIdentifier = "0E9E98B01BBC8A02004FFE25"
+            BuildableName = "datamodel"
+            BlueprintName = "datamodel"
+            ReferencedContainer = "container:datamodel.xcodeproj">
+         </BuildableReference>
+      </MacroExpansion>
+   </ProfileAction>
+   <AnalyzeAction
+      buildConfiguration = "Debug">
+   </AnalyzeAction>
+   <ArchiveAction
+      buildConfiguration = "Release"
+      revealArchiveInOrganizer = "YES">
+   </ArchiveAction>
+</Scheme>

+ 22 - 0
datamodel.xcodeproj/xcuserdata/leumasjaffe.xcuserdatad/xcschemes/xcschememanagement.plist

@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+	<key>SchemeUserState</key>
+	<dict>
+		<key>datamodel.xcscheme</key>
+		<dict>
+			<key>orderHint</key>
+			<integer>8</integer>
+		</dict>
+	</dict>
+	<key>SuppressBuildableAutocreation</key>
+	<dict>
+		<key>0E9E98B01BBC8A02004FFE25</key>
+		<dict>
+			<key>primary</key>
+			<true/>
+		</dict>
+	</dict>
+</dict>
+</plist>

+ 80 - 0
datamodel.xcodeproj/xcuserdata/samjaffe.xcuserdatad/xcschemes/datamodel.xcscheme

@@ -0,0 +1,80 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Scheme
+   LastUpgradeVersion = "0720"
+   version = "1.3">
+   <BuildAction
+      parallelizeBuildables = "YES"
+      buildImplicitDependencies = "YES">
+      <BuildActionEntries>
+         <BuildActionEntry
+            buildForTesting = "YES"
+            buildForRunning = "YES"
+            buildForProfiling = "YES"
+            buildForArchiving = "YES"
+            buildForAnalyzing = "YES">
+            <BuildableReference
+               BuildableIdentifier = "primary"
+               BlueprintIdentifier = "0E9E98B01BBC8A02004FFE25"
+               BuildableName = "datamodel"
+               BlueprintName = "datamodel"
+               ReferencedContainer = "container:datamodel.xcodeproj">
+            </BuildableReference>
+         </BuildActionEntry>
+      </BuildActionEntries>
+   </BuildAction>
+   <TestAction
+      buildConfiguration = "Debug"
+      selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
+      selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
+      shouldUseLaunchSchemeArgsEnv = "YES">
+      <Testables>
+      </Testables>
+      <AdditionalOptions>
+      </AdditionalOptions>
+   </TestAction>
+   <LaunchAction
+      buildConfiguration = "Debug"
+      selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
+      selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
+      launchStyle = "0"
+      useCustomWorkingDirectory = "NO"
+      ignoresPersistentStateOnLaunch = "NO"
+      debugDocumentVersioning = "YES"
+      debugServiceExtension = "internal"
+      allowLocationSimulation = "YES">
+      <MacroExpansion>
+         <BuildableReference
+            BuildableIdentifier = "primary"
+            BlueprintIdentifier = "0E9E98B01BBC8A02004FFE25"
+            BuildableName = "datamodel"
+            BlueprintName = "datamodel"
+            ReferencedContainer = "container:datamodel.xcodeproj">
+         </BuildableReference>
+      </MacroExpansion>
+      <AdditionalOptions>
+      </AdditionalOptions>
+   </LaunchAction>
+   <ProfileAction
+      buildConfiguration = "Release"
+      shouldUseLaunchSchemeArgsEnv = "YES"
+      savedToolIdentifier = ""
+      useCustomWorkingDirectory = "NO"
+      debugDocumentVersioning = "YES">
+      <MacroExpansion>
+         <BuildableReference
+            BuildableIdentifier = "primary"
+            BlueprintIdentifier = "0E9E98B01BBC8A02004FFE25"
+            BuildableName = "datamodel"
+            BlueprintName = "datamodel"
+            ReferencedContainer = "container:datamodel.xcodeproj">
+         </BuildableReference>
+      </MacroExpansion>
+   </ProfileAction>
+   <AnalyzeAction
+      buildConfiguration = "Debug">
+   </AnalyzeAction>
+   <ArchiveAction
+      buildConfiguration = "Release"
+      revealArchiveInOrganizer = "YES">
+   </ArchiveAction>
+</Scheme>

+ 22 - 0
datamodel.xcodeproj/xcuserdata/samjaffe.xcuserdatad/xcschemes/xcschememanagement.plist

@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+	<key>SchemeUserState</key>
+	<dict>
+		<key>datamodel.xcscheme</key>
+		<dict>
+			<key>orderHint</key>
+			<integer>11</integer>
+		</dict>
+	</dict>
+	<key>SuppressBuildableAutocreation</key>
+	<dict>
+		<key>0E9E98B01BBC8A02004FFE25</key>
+		<dict>
+			<key>primary</key>
+			<true/>
+		</dict>
+	</dict>
+</dict>
+</plist>

+ 132 - 0
rotate.hpp

@@ -0,0 +1,132 @@
+#include <vector>
+#include <cstdlib>
+#include <boost/preprocessor.hpp>
+
+template <typename T, typename I, I T::*mem>
+struct access {
+  using value_type = I;
+  using access_type = T;
+  
+  value_type& get(access_type& t) const { return t.*mem; }
+  value_type const& get(access_type const& t) const { return t.*mem; }
+};
+
+template <typename T, typename...Members>
+class rotate;
+
+template <typename T, typename...Members> class proxy;
+
+template <typename T, typename Member>
+class rotate<T, Member> {
+public:
+  using value_type = typename Member::value_type;
+  using data_type = std::vector<value_type>;
+  
+  value_type&       get(size_t n, Member) { return rotated_.at(n); }
+  value_type const& get(size_t n, Member) const { return rotated_.at(n); }
+  
+  data_type const&  get(Member) const { return rotated_; }
+
+protected:
+  void push_back(T const& t) {
+    rotated_.push_back(Member().get(t));
+  }
+
+private:
+  data_type rotated_;
+};
+
+template <typename T, typename Member0, typename...Members>
+class rotate<T, Member0, Members...> : public rotate<T, Member0>, public rotate<T, Members...> {
+public:
+  proxy<T, Member0, Members...> get(size_t n);
+
+  void push_back(T const& t) {
+    rotate<T, Member0>::push_back(t);
+    rotate<T, Members...>::push_back(t);
+  }
+  
+  using rotate<T, Member0>::get;
+  using rotate<T, Members...>::get;
+};
+
+#define PROXY_ELEMENT(T, elem) decltype(T::elem)& elem
+#define PROXY_MEMBER(r, T, elem) PROXY_ELEMENT(T, elem);
+#define PROXY_CONSTR(r, T, elem) BOOST_PP_CAT(PROXY_ELEMENT(T, elem),_),
+#define PROXY_INIT(r, T, elem) elem(BOOST_PP_CAT(elem,_)),
+#define PROXY_SET(r, t, elem) t.elem = elem;
+
+#define proxy_t(T, mseq) proxy<T BOOST_PP_SEQ_FOR_EACH(ROTATE_ACCESS, T, mseq)>
+
+#define ROTATE_PROXY(T, mseq) \
+  template<> class proxy_t(T, mseq) { \
+  public: \
+    proxy(BOOST_PP_SEQ_FOR_EACH(PROXY_CONSTR, T, mseq) bool) \
+    : BOOST_PP_SEQ_FOR_EACH(PROXY_INIT, T, mseq) dummy(false) {} \
+    \
+    explicit operator T() const { \
+      T t; \
+      BOOST_PP_SEQ_FOR_EACH(PROXY_SET, t, mseq) \
+      return t; \
+    } \
+    \
+    BOOST_PP_SEQ_FOR_EACH(PROXY_MEMBER, T, mseq) \
+    bool dummy; \
+  }
+
+#define ROTATE_ACCESS(r, T, elem) ,access_t(T, elem)
+#define PROXY_ASSIGN(r, T, elem) rotate<T, access_t(T, elem)>::get(n, access_t(T, elem)()),
+
+#define rotate_t(T, mseq) rotate<T BOOST_PP_SEQ_FOR_EACH(ROTATE_ACCESS, T, mseq)>
+#define access_t(T, M) access<T, decltype(T::M), &T::M>
+
+//#define DEFINE_ROTATE_NAME(name, T, mseq) \
+//  using name = rotate_t(T, mseq); \
+//  ROTATE_PROXY(T, mseq); \
+//  template <typename T, typename M0, typename...Ms> \
+//  proxy<T, M0, Ms...> rotate<T, M0, Ms...>::get(size_t n) { \
+//    return proxy<T, M0, Ms...>{BOOST_PP_SEQ_FOR_EACH(PROXY_ASSIGN, T, mseq) false}; \
+//  }
+
+#define DEFINE_ROTATE_NAME(name, T, mseq) \
+  ROTATE_PROXY(T, mseq); \
+  class name : public rotate_t(T, mseq) { \
+  public:\
+    proxy_t(T, mseq) get(size_t n) { \
+    return proxy_t(T, mseq){BOOST_PP_SEQ_FOR_EACH(PROXY_ASSIGN, T, mseq) false}; \
+    } \
+    using rotate_t(T, mseq)::get; \
+  }
+
+#define DEFINE_ROTATE(T, mseq) DEFINE_ROTATE_NAME(T##_rotate, T, mseq)
+
+//#include <iostream>
+//
+//struct particle {
+//  int x, y, dx, dy;
+//  char color;
+//};
+//
+//DEFINE_ROTATE(particle, (color)(x)(y)(dx)(dy))
+//
+//int main(int argc, char const *argv[]) {
+//  (void) argc;
+//  (void) argv;
+//  particle p{0, 0, 0, 0, 0};
+//  particle_rotate pr;
+//  pr.push_back(p);
+//
+//  {
+//    proxy<particle> pp = pr.get(0);
+//    pp.x = 5;
+//  }
+//
+//  {
+//    proxy<particle> pp = pr.get(0);
+//    std::cout << pp.x << std::endl;
+//    particle copy = particle(pp);
+//    std::cout << copy.x << std::endl;
+//  }
+//  
+//  return 0;
+//}

+ 49 - 0
rotate_tc.cpp

@@ -0,0 +1,49 @@
+/* Generated file, do not edit */
+
+#ifndef CXXTEST_RUNNING
+#define CXXTEST_RUNNING
+#endif
+
+#define _CXXTEST_HAVE_STD
+#include <cxxtest/TestListener.h>
+#include <cxxtest/TestTracker.h>
+#include <cxxtest/TestRunner.h>
+#include <cxxtest/RealDescriptions.h>
+#include <cxxtest/TestMain.h>
+#include <cxxtest/ErrorPrinter.h>
+
+int main( int argc, char *argv[] ) {
+ int status;
+    CxxTest::ErrorPrinter tmp;
+    CxxTest::RealWorldDescription::_worldName = "cxxtest";
+    status = CxxTest::Main< CxxTest::ErrorPrinter >( tmp, argc, argv );
+    return status;
+}
+bool suite_rotate_TestSuite_init = false;
+#include "rotate_tc.h"
+
+static rotate_TestSuite suite_rotate_TestSuite;
+
+static CxxTest::List Tests_rotate_TestSuite = { 0, 0 };
+CxxTest::StaticSuiteDescription suiteDescription_rotate_TestSuite( "rotate_tc.h", 77, "rotate_TestSuite", suite_rotate_TestSuite, Tests_rotate_TestSuite );
+
+static class TestDescription_suite_rotate_TestSuite_test_proxy1 : public CxxTest::RealTestDescription {
+public:
+ TestDescription_suite_rotate_TestSuite_test_proxy1() : CxxTest::RealTestDescription( Tests_rotate_TestSuite, suiteDescription_rotate_TestSuite, 79, "test_proxy1" ) {}
+ void runTest() { suite_rotate_TestSuite.test_proxy1(); }
+} testDescription_suite_rotate_TestSuite_test_proxy1;
+
+static class TestDescription_suite_rotate_TestSuite_test_proxy2 : public CxxTest::RealTestDescription {
+public:
+ TestDescription_suite_rotate_TestSuite_test_proxy2() : CxxTest::RealTestDescription( Tests_rotate_TestSuite, suiteDescription_rotate_TestSuite, 91, "test_proxy2" ) {}
+ void runTest() { suite_rotate_TestSuite.test_proxy2(); }
+} testDescription_suite_rotate_TestSuite_test_proxy2;
+
+static class TestDescription_suite_rotate_TestSuite_test_datamodel_center : public CxxTest::RealTestDescription {
+public:
+ TestDescription_suite_rotate_TestSuite_test_datamodel_center() : CxxTest::RealTestDescription( Tests_rotate_TestSuite, suiteDescription_rotate_TestSuite, 101, "test_datamodel_center" ) {}
+ void runTest() { suite_rotate_TestSuite.test_datamodel_center(); }
+} testDescription_suite_rotate_TestSuite_test_datamodel_center;
+
+#include <cxxtest/Root.cpp>
+const char* CxxTest::RealWorldDescription::_worldName = "cxxtest";

+ 111 - 0
rotate_tc.h

@@ -0,0 +1,111 @@
+//
+//  rotate_tc.h
+//  datamodel
+//
+//  Created by Sam Jaffe on 9/30/15.
+//
+//
+
+#include <cxxtest/TestSuite.h>
+
+#include "rotate.hpp"
+
+struct Point {
+  float x = 0.f, y = 0.f;
+  
+  Point() = default;
+  Point(float _x, float _y) : x(_x), y(_y) {}
+  
+  bool operator==(const Point& other) const {
+    return !memcmp(this, &other, sizeof(*this));
+  }
+};
+
+struct Dimension {
+  float width = 0.f, height = 0.f;
+  
+  Dimension() = default;
+  Dimension(float w, float h) : width(w), height(h) {}
+  
+  bool operator==(const Dimension& other) const {
+    return !memcmp(this, &other, sizeof(*this));
+  }
+};
+
+struct Material {
+  int id = -1;
+  
+  Material() = default;
+  Material(int i) : id(i) {}
+  
+  bool operator==(const Material& other) const {
+    return !memcmp(this, &other, sizeof(*this));
+  }
+};
+
+struct RenderInfo {
+  Point center;
+  Material material;
+  Dimension texture_size, object_size;
+  Point bottom_left, bottom_right, top_right, top_left;
+  float rotation = 0.0f; // TODO
+  
+  RenderInfo(Point c, Dimension sz, Material mat = {0}, Dimension tx_sz = {1.f, 1.f})
+  : center(c)
+  , material(mat)
+  , texture_size(tx_sz)
+  , object_size(sz)
+  , bottom_left ({c.x - sz.width / 2.f, c.y - sz.height / 2.f})
+  , bottom_right({c.x - sz.width / 2.f, c.y + sz.height / 2.f})
+  , top_right   ({c.x + sz.width / 2.f, c.y + sz.height / 2.f})
+  , top_left    ({c.x + sz.width / 2.f, c.y - sz.height / 2.f})
+  {
+    
+  }
+  
+  RenderInfo() = default;
+  
+  bool operator==(const RenderInfo& other) const {
+    return !memcmp(this, &other, sizeof(*this));
+  }
+};
+
+DEFINE_ROTATE(RenderInfo, (material)(texture_size)(bottom_left)(bottom_right)(top_right)(top_left));
+
+DEFINE_ROTATE_NAME(simple_rotate, RenderInfo, (material)(texture_size)(center)(object_size));
+
+class rotate_TestSuite : public CxxTest::TestSuite {
+public:
+  void test_proxy1() const {
+    RenderInfo_rotate rdata;
+    RenderInfo info{{5, 6}, {1, 1}};
+    rdata.push_back(info);
+    auto proxy = rdata.get(0);
+    TS_ASSERT_EQUALS(info.texture_size, proxy.texture_size);
+    TS_ASSERT_EQUALS(info.bottom_left, proxy.bottom_left);
+    TS_ASSERT_EQUALS(info.bottom_right, proxy.bottom_right);
+    TS_ASSERT_EQUALS(info.top_left, proxy.top_left);
+    TS_ASSERT_EQUALS(info.top_right, proxy.top_right);
+  }
+  
+  void test_proxy2() const {
+    simple_rotate rdata;
+    RenderInfo info{{5, 6}, {1, 1}};
+    rdata.push_back(info);
+    auto proxy = rdata.get(0);
+    TS_ASSERT_EQUALS(info.texture_size, proxy.texture_size);
+    TS_ASSERT_EQUALS(info.center, proxy.center);
+    TS_ASSERT_EQUALS(info.object_size, proxy.object_size);
+  }
+
+  void test_datamodel_center() const {
+    simple_rotate rdata;
+    RenderInfo infos[3] = {{{1,2},{1,1}},{{0,3},{1,1}},{{4,3.2},{1,1}}};
+    rdata.push_back(infos[0]);
+    rdata.push_back(infos[1]);
+    rdata.push_back(infos[2]);
+    TS_ASSERT_EQUALS(rdata.get(access_t(RenderInfo, center){}), (std::vector<Point>{{1,2},{0,3},{4,3.2}}));
+  }
+private:
+  
+};