src/Factory.cpp
author František Kučera <franta-hg@frantovo.cz>
Sun, 26 May 2019 22:22:59 +0200
branchv_0
changeset 39 acf95eeefe8b
parent 30 3f18cb7a6963
child 41 744b61559eb2
permissions -rw-r--r--
Added tag v0.12 for changeset ad8e76bc916d
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;
3f18cb7a6963 license of protocol, reader and writer: GNU LGPLv3+ or GNU GPLv2+
František Kučera <franta-hg@frantovo.cz>
parents: 29
diff changeset
     8
 *    either version 3 of the License, or (at your option) any later version;
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
 *    or (at your option)
3f18cb7a6963 license of protocol, reader and writer: GNU LGPLv3+ or GNU GPLv2+
František Kučera <franta-hg@frantovo.cz>
parents: 29
diff changeset
    10
 *  - GNU General Public License as published by the Free Software Foundation;
3f18cb7a6963 license of protocol, reader and writer: GNU LGPLv3+ or GNU GPLv2+
František Kučera <franta-hg@frantovo.cz>
parents: 29
diff changeset
    11
 *    either version 2 of the License, or (at your option) any later version.
29
142bdbba520f license: GNU GPLv3+
František Kučera <franta-hg@frantovo.cz>
parents: 25
diff changeset
    12
 *
142bdbba520f license: GNU GPLv3+
František Kučera <franta-hg@frantovo.cz>
parents: 25
diff changeset
    13
 * 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
    14
 * 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
    15
 * 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
    16
 * GNU General Public License for more details.
142bdbba520f license: GNU GPLv3+
František Kučera <franta-hg@frantovo.cz>
parents: 25
diff changeset
    17
 *
142bdbba520f license: GNU GPLv3+
František Kučera <franta-hg@frantovo.cz>
parents: 25
diff changeset
    18
 * 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
    19
 * 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
    20
 */
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
    21
#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
    22
25
135ef93a4ac2 imports, namespaces
František Kučera <franta-hg@frantovo.cz>
parents: 21
diff changeset
    23
#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
    24
#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
    25
#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
    26
#include "StreamRelationalWriter.h"
0a40752e401d shared library with pure abstract class (interface)
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    27
0a40752e401d shared library with pure abstract class (interface)
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    28
namespace relpipe {
0a40752e401d shared library with pure abstract class (interface)
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    29
namespace writer {
0a40752e401d shared library with pure abstract class (interface)
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    30
14
733334eca89b move create() method to a factory
František Kučera <franta-hg@frantovo.cz>
parents: 9
diff changeset
    31
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
    32
	return new StreamRelationalWriter(output);
0a40752e401d shared library with pure abstract class (interface)
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    33
}
0a40752e401d shared library with pure abstract class (interface)
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    34
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
    35
/**
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
 * 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
    37
 * 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
    38
 */
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
#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
    40
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
    41
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
    42
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
    43
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
#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
    45
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
    46
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
    47
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
    48
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
    49
9
0a40752e401d shared library with pure abstract class (interface)
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    50
}
0a40752e401d shared library with pure abstract class (interface)
František Kučera <franta-hg@frantovo.cz>
parents:
diff changeset
    51
}