src/Factory.cpp
author František Kučera <franta-hg@frantovo.cz>
Sat, 25 Aug 2018 18:21:09 +0200
branchv_0
changeset 25 135ef93a4ac2
parent 21 118b68d73420
child 29 142bdbba520f
permissions -rw-r--r--
imports, namespaces
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
21
118b68d73420 static_assert to enforce compliance with common constants in lib-protocol
František Kučera <franta-hg@frantovo.cz>
parents: 20
diff changeset
     1
#include <relpipe/protocol/constants.h>
118b68d73420 static_assert to enforce compliance with common constants in lib-protocol
František Kučera <franta-hg@frantovo.cz>
parents: 20
diff changeset
     2
25
135ef93a4ac2 imports, namespaces
František Kučera <franta-hg@frantovo.cz>
parents: 21
diff changeset
     3
#include "../include/relpipe/writer/TypeId.h"
20
bef6648e79b1 relpipe-lib-writer: move public header files to: include/relpipe/writer/
František Kučera <franta-hg@frantovo.cz>
parents: 14
diff changeset
     4
#include "../include/relpipe/writer/RelationalWriter.h"
bef6648e79b1 relpipe-lib-writer: move public header files to: include/relpipe/writer/
František Kučera <franta-hg@frantovo.cz>
parents: 14
diff changeset
     5
#include "../include/relpipe/writer/Factory.h"
9
0a40752e401d shared library with pure abstract class (interface)
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     6
#include "StreamRelationalWriter.h"
0a40752e401d shared library with pure abstract class (interface)
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     7
0a40752e401d shared library with pure abstract class (interface)
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     8
namespace relpipe {
0a40752e401d shared library with pure abstract class (interface)
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
     9
namespace writer {
0a40752e401d shared library with pure abstract class (interface)
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    10
14
733334eca89b move create() method to a factory
František Kučera <franta-hg@frantovo.cz>
parents: 9
diff changeset
    11
RelationalWriter* Factory::create(std::ostream& output) {
9
0a40752e401d shared library with pure abstract class (interface)
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    12
	return new StreamRelationalWriter(output);
0a40752e401d shared library with pure abstract class (interface)
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    13
}
0a40752e401d shared library with pure abstract class (interface)
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    14
21
118b68d73420 static_assert to enforce compliance with common constants in lib-protocol
František Kučera <franta-hg@frantovo.cz>
parents: 20
diff changeset
    15
/**
118b68d73420 static_assert to enforce compliance with common constants in lib-protocol
František Kučera <franta-hg@frantovo.cz>
parents: 20
diff changeset
    16
 * Some basic constants defined in lib-protocol are re-exported in public headers of lib-reader and lib-writer,
118b68d73420 static_assert to enforce compliance with common constants in lib-protocol
František Kučera <franta-hg@frantovo.cz>
parents: 20
diff changeset
    17
 * so we should check (during compile-time) that they match.
118b68d73420 static_assert to enforce compliance with common constants in lib-protocol
František Kučera <franta-hg@frantovo.cz>
parents: 20
diff changeset
    18
 */
118b68d73420 static_assert to enforce compliance with common constants in lib-protocol
František Kučera <franta-hg@frantovo.cz>
parents: 20
diff changeset
    19
#define PROTOCOL_VIOLATION_TYPE_ID_ERROR "type id does not match with protocol"
118b68d73420 static_assert to enforce compliance with common constants in lib-protocol
František Kučera <franta-hg@frantovo.cz>
parents: 20
diff changeset
    20
static_assert((int) TypeId::BOOLEAN == relpipe::protocol::DATA_TYPE_ID_BOOLEAN, PROTOCOL_VIOLATION_TYPE_ID_ERROR);
118b68d73420 static_assert to enforce compliance with common constants in lib-protocol
František Kučera <franta-hg@frantovo.cz>
parents: 20
diff changeset
    21
static_assert((int) TypeId::STRING == relpipe::protocol::DATA_TYPE_ID_STRING, PROTOCOL_VIOLATION_TYPE_ID_ERROR);
118b68d73420 static_assert to enforce compliance with common constants in lib-protocol
František Kučera <franta-hg@frantovo.cz>
parents: 20
diff changeset
    22
static_assert((int) TypeId::INTEGER == relpipe::protocol::DATA_TYPE_ID_INTEGER, PROTOCOL_VIOLATION_TYPE_ID_ERROR);
118b68d73420 static_assert to enforce compliance with common constants in lib-protocol
František Kučera <franta-hg@frantovo.cz>
parents: 20
diff changeset
    23
118b68d73420 static_assert to enforce compliance with common constants in lib-protocol
František Kučera <franta-hg@frantovo.cz>
parents: 20
diff changeset
    24
#define PROTOCOL_VIOLATION_TYPE_DEF_ERROR "type definition does not match with protocol"
118b68d73420 static_assert to enforce compliance with common constants in lib-protocol
František Kučera <franta-hg@frantovo.cz>
parents: 20
diff changeset
    25
static_assert(std::is_same<relpipe::writer::boolean_t, typename relpipe::protocol::boolean_t>::value, PROTOCOL_VIOLATION_TYPE_DEF_ERROR);
118b68d73420 static_assert to enforce compliance with common constants in lib-protocol
František Kučera <franta-hg@frantovo.cz>
parents: 20
diff changeset
    26
static_assert(std::is_same<relpipe::writer::integer_t, typename relpipe::protocol::integer_t>::value, PROTOCOL_VIOLATION_TYPE_DEF_ERROR);
118b68d73420 static_assert to enforce compliance with common constants in lib-protocol
František Kučera <franta-hg@frantovo.cz>
parents: 20
diff changeset
    27
static_assert(std::is_same<relpipe::writer::string_t, typename relpipe::protocol::string_t>::value, PROTOCOL_VIOLATION_TYPE_DEF_ERROR);
118b68d73420 static_assert to enforce compliance with common constants in lib-protocol
František Kučera <franta-hg@frantovo.cz>
parents: 20
diff changeset
    28
static_assert(std::is_same<relpipe::writer::octet_t, typename relpipe::protocol::octet_t>::value, PROTOCOL_VIOLATION_TYPE_DEF_ERROR);
118b68d73420 static_assert to enforce compliance with common constants in lib-protocol
František Kučera <franta-hg@frantovo.cz>
parents: 20
diff changeset
    29
9
0a40752e401d shared library with pure abstract class (interface)
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    30
}
0a40752e401d shared library with pure abstract class (interface)
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    31
}