move create() method to a factory v_0
authorFrantišek Kučera <franta-hg@frantovo.cz>
Sun, 22 Jul 2018 00:08:13 +0200
branchv_0
changeset 14 733334eca89b
parent 13 e7234dd45166
child 15 8fd6c4d44071
move create() method to a factory
include/Factory.h
include/RelationalWriter.h
nbproject/Makefile-Debug.mk
nbproject/Makefile-Release.mk
nbproject/configurations.xml
src/Factory.cpp
src/RelationalWriter.cpp
src/StreamRelationalWriter.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/include/Factory.h	Sun Jul 22 00:08:13 2018 +0200
@@ -0,0 +1,19 @@
+#pragma once
+
+#include <string>
+#include <iostream>
+#include <vector>
+
+#include "typedefs.h"
+#include "TypeId.h"
+
+namespace relpipe {
+namespace writer {
+
+class Factory {
+public:
+	static RelationalWriter* create(std::ostream &output);
+};
+
+}
+}
--- a/include/RelationalWriter.h	Sat Jul 21 23:46:29 2018 +0200
+++ b/include/RelationalWriter.h	Sun Jul 22 00:08:13 2018 +0200
@@ -23,7 +23,6 @@
 
 	virtual void writeRecord(std::vector<string_t> attributes) = 0;
 
-	static RelationalWriter* create(std::ostream &output);
 };
 
 }
--- a/nbproject/Makefile-Debug.mk	Sat Jul 21 23:46:29 2018 +0200
+++ b/nbproject/Makefile-Debug.mk	Sun Jul 22 00:08:13 2018 +0200
@@ -35,7 +35,7 @@
 
 # Object Files
 OBJECTFILES= \
-	${OBJECTDIR}/src/RelationalWriter.o
+	${OBJECTDIR}/src/Factory.o
 
 
 # C Compiler Flags
@@ -62,10 +62,10 @@
 	${MKDIR} -p ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}
 	${LINK.cc} -o ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/librelpipe-lib-writer.cpp.${CND_DLIB_EXT} ${OBJECTFILES} ${LDLIBSOPTIONS} -shared -fPIC
 
-${OBJECTDIR}/src/RelationalWriter.o: src/RelationalWriter.cpp
+${OBJECTDIR}/src/Factory.o: src/Factory.cpp
 	${MKDIR} -p ${OBJECTDIR}/src
 	${RM} "$@.d"
-	$(COMPILE.cc) -g -fPIC  -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/src/RelationalWriter.o src/RelationalWriter.cpp
+	$(COMPILE.cc) -g -fPIC  -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/src/Factory.o src/Factory.cpp
 
 # Subprojects
 .build-subprojects:
--- a/nbproject/Makefile-Release.mk	Sat Jul 21 23:46:29 2018 +0200
+++ b/nbproject/Makefile-Release.mk	Sun Jul 22 00:08:13 2018 +0200
@@ -35,7 +35,7 @@
 
 # Object Files
 OBJECTFILES= \
-	${OBJECTDIR}/src/RelationalWriter.o
+	${OBJECTDIR}/src/Factory.o
 
 
 # C Compiler Flags
@@ -62,10 +62,10 @@
 	${MKDIR} -p ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}
 	${LINK.cc} -o ${CND_DISTDIR}/${CND_CONF}/${CND_PLATFORM}/librelpipe-lib-writer.cpp.${CND_DLIB_EXT} ${OBJECTFILES} ${LDLIBSOPTIONS} -shared -fPIC
 
-${OBJECTDIR}/src/RelationalWriter.o: src/RelationalWriter.cpp
+${OBJECTDIR}/src/Factory.o: src/Factory.cpp
 	${MKDIR} -p ${OBJECTDIR}/src
 	${RM} "$@.d"
-	$(COMPILE.cc) -O2 -fPIC  -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/src/RelationalWriter.o src/RelationalWriter.cpp
+	$(COMPILE.cc) -O2 -fPIC  -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/src/Factory.o src/Factory.cpp
 
 # Subprojects
 .build-subprojects:
--- a/nbproject/configurations.xml	Sat Jul 21 23:46:29 2018 +0200
+++ b/nbproject/configurations.xml	Sun Jul 22 00:08:13 2018 +0200
@@ -7,6 +7,7 @@
       <itemPath>src/types/BooleanDataTypeWriter.h</itemPath>
       <itemPath>src/DataTypeWriter.h</itemPath>
       <itemPath>src/DataTypeWriterBase.h</itemPath>
+      <itemPath>include/Factory.h</itemPath>
       <itemPath>src/types/IntegerDataTypeWriter.h</itemPath>
       <itemPath>include/RelationalWriter.h</itemPath>
       <itemPath>include/RelpipeWriterException.h</itemPath>
@@ -23,7 +24,7 @@
     <logicalFolder name="SourceFiles"
                    displayName="Source Files"
                    projectFiles="true">
-      <itemPath>src/RelationalWriter.cpp</itemPath>
+      <itemPath>src/Factory.cpp</itemPath>
     </logicalFolder>
     <logicalFolder name="TestFiles"
                    displayName="Test Files"
@@ -47,6 +48,8 @@
       </toolsSet>
       <compileType>
       </compileType>
+      <item path="include/Factory.h" ex="false" tool="3" flavor2="0">
+      </item>
       <item path="include/RelationalWriter.h" ex="false" tool="3" flavor2="0">
       </item>
       <item path="include/RelpipeWriterException.h" ex="false" tool="3" flavor2="0">
@@ -59,7 +62,7 @@
       </item>
       <item path="src/DataTypeWriterBase.h" ex="false" tool="3" flavor2="0">
       </item>
-      <item path="src/RelationalWriter.cpp" ex="false" tool="1" flavor2="0">
+      <item path="src/Factory.cpp" ex="false" tool="1" flavor2="0">
       </item>
       <item path="src/StreamRelationalWriter.h" ex="false" tool="3" flavor2="0">
       </item>
@@ -92,6 +95,8 @@
           <developmentMode>5</developmentMode>
         </asmTool>
       </compileType>
+      <item path="include/Factory.h" ex="false" tool="3" flavor2="0">
+      </item>
       <item path="include/RelationalWriter.h" ex="false" tool="3" flavor2="0">
       </item>
       <item path="include/RelpipeWriterException.h" ex="false" tool="3" flavor2="0">
@@ -104,7 +109,7 @@
       </item>
       <item path="src/DataTypeWriterBase.h" ex="false" tool="3" flavor2="0">
       </item>
-      <item path="src/RelationalWriter.cpp" ex="false" tool="1" flavor2="0">
+      <item path="src/Factory.cpp" ex="false" tool="1" flavor2="0">
       </item>
       <item path="src/StreamRelationalWriter.h" ex="false" tool="3" flavor2="0">
       </item>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/Factory.cpp	Sun Jul 22 00:08:13 2018 +0200
@@ -0,0 +1,13 @@
+#include "../include/RelationalWriter.h"
+#include "../include/Factory.h"
+#include "StreamRelationalWriter.h"
+
+namespace relpipe {
+namespace writer {
+
+RelationalWriter* Factory::create(std::ostream& output) {
+	return new StreamRelationalWriter(output);
+}
+
+}
+}
\ No newline at end of file
--- a/src/RelationalWriter.cpp	Sat Jul 21 23:46:29 2018 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,12 +0,0 @@
-#include "../include/RelationalWriter.h"
-#include "StreamRelationalWriter.h"
-
-namespace relpipe {
-namespace writer {
-
-RelationalWriter* RelationalWriter::create(std::ostream& output) {
-	return new StreamRelationalWriter(output);
-}
-
-}
-}
\ No newline at end of file
--- a/src/StreamRelationalWriter.h	Sat Jul 21 23:46:29 2018 +0200
+++ b/src/StreamRelationalWriter.h	Sun Jul 22 00:08:13 2018 +0200
@@ -69,7 +69,7 @@
 
 		// Write column names:
 		for (size_t c = 0; c < columnCount; c++) {
-			wstring columnName = attributes[c].first;
+			wstring columnName = attributes[c].first;			
 			stringWriter.writeValue(output, columnName);
 		}