src/Factory.cpp
author František Kučera <franta-hg@frantovo.cz>
Tue, 22 Oct 2019 19:47:14 +0200
branchv_0
changeset 41 744b61559eb2
parent 30 3f18cb7a6963
permissions -rw-r--r--
fix license version: GNU LGPLv3 or GPLv2
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
29
142bdbba520f license: GNU GPLv3+
František Kučera <franta-hg@frantovo.cz>
parents: 25
diff changeset
     1
/**
30
3f18cb7a6963 license of protocol, reader and writer: GNU LGPLv3+ or GNU GPLv2+
František Kučera <franta-hg@frantovo.cz>
parents: 29
diff changeset
     2
 * Relational pipes (library)
29
142bdbba520f license: GNU GPLv3+
František Kučera <franta-hg@frantovo.cz>
parents: 25
diff changeset
     3
 * Copyright © 2018 František Kučera (Frantovo.cz, GlobalCode.info)
142bdbba520f license: GNU GPLv3+
František Kučera <franta-hg@frantovo.cz>
parents: 25
diff changeset
     4
 *
142bdbba520f license: GNU GPLv3+
František Kučera <franta-hg@frantovo.cz>
parents: 25
diff changeset
     5
 * This program is free software: you can redistribute it and/or modify
30
3f18cb7a6963 license of protocol, reader and writer: GNU LGPLv3+ or GNU GPLv2+
František Kučera <franta-hg@frantovo.cz>
parents: 29
diff changeset
     6
 * it under the terms of the:
3f18cb7a6963 license of protocol, reader and writer: GNU LGPLv3+ or GNU GPLv2+
František Kučera <franta-hg@frantovo.cz>
parents: 29
diff changeset
     7
 *  - GNU Lesser General Public License as published by the Free Software Foundation;
41
744b61559eb2 fix license version: GNU LGPLv3 or GPLv2
František Kučera <franta-hg@frantovo.cz>
parents: 30
diff changeset
     8
 *    version 3 of the License or (at your option)
30
3f18cb7a6963 license of protocol, reader and writer: GNU LGPLv3+ or GNU GPLv2+
František Kučera <franta-hg@frantovo.cz>
parents: 29
diff changeset
     9
 *  - GNU General Public License as published by the Free Software Foundation;
41
744b61559eb2 fix license version: GNU LGPLv3 or GPLv2
František Kučera <franta-hg@frantovo.cz>
parents: 30
diff changeset
    10
 *    version 2 of the License.
29
142bdbba520f license: GNU GPLv3+
František Kučera <franta-hg@frantovo.cz>
parents: 25
diff changeset
    11
 *
142bdbba520f license: GNU GPLv3+
František Kučera <franta-hg@frantovo.cz>
parents: 25
diff changeset
    12
 * This program is distributed in the hope that it will be useful,
142bdbba520f license: GNU GPLv3+
František Kučera <franta-hg@frantovo.cz>
parents: 25
diff changeset
    13
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
142bdbba520f license: GNU GPLv3+
František Kučera <franta-hg@frantovo.cz>
parents: 25
diff changeset
    14
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
142bdbba520f license: GNU GPLv3+
František Kučera <franta-hg@frantovo.cz>
parents: 25
diff changeset
    15
 * GNU General Public License for more details.
142bdbba520f license: GNU GPLv3+
František Kučera <franta-hg@frantovo.cz>
parents: 25
diff changeset
    16
 *
142bdbba520f license: GNU GPLv3+
František Kučera <franta-hg@frantovo.cz>
parents: 25
diff changeset
    17
 * You should have received a copy of the GNU General Public License
142bdbba520f license: GNU GPLv3+
František Kučera <franta-hg@frantovo.cz>
parents: 25
diff changeset
    18
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
142bdbba520f license: GNU GPLv3+
František Kučera <franta-hg@frantovo.cz>
parents: 25
diff changeset
    19
 */
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
    20
#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
    21
25
135ef93a4ac2 imports, namespaces
František Kučera <franta-hg@frantovo.cz>
parents: 21
diff changeset
    22
#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
    23
#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
    24
#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
    25
#include "StreamRelationalWriter.h"
0a40752e401d shared library with pure abstract class (interface)
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    26
0a40752e401d shared library with pure abstract class (interface)
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    27
namespace relpipe {
0a40752e401d shared library with pure abstract class (interface)
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    28
namespace writer {
0a40752e401d shared library with pure abstract class (interface)
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    29
14
733334eca89b move create() method to a factory
František Kučera <franta-hg@frantovo.cz>
parents: 9
diff changeset
    30
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
    31
	return new StreamRelationalWriter(output);
0a40752e401d shared library with pure abstract class (interface)
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    32
}
0a40752e401d shared library with pure abstract class (interface)
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    33
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
    34
/**
118b68d73420 static_assert to enforce compliance with common constants in lib-protocol
František Kučera <franta-hg@frantovo.cz>
parents: 20
diff changeset
    35
 * 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
    36
 * 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
    37
 */
118b68d73420 static_assert to enforce compliance with common constants in lib-protocol
František Kučera <franta-hg@frantovo.cz>
parents: 20
diff changeset
    38
#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
    39
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
    40
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
    41
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
    42
118b68d73420 static_assert to enforce compliance with common constants in lib-protocol
František Kučera <franta-hg@frantovo.cz>
parents: 20
diff changeset
    43
#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
    44
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
    45
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
    46
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
    47
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
    48
9
0a40752e401d shared library with pure abstract class (interface)
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    49
}
0a40752e401d shared library with pure abstract class (interface)
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    50
}