src/Factory.cpp
branchv_0
changeset 14 e8de089f95dd
child 19 3e1308e7606d
equal deleted inserted replaced
13:543f1613c2da 14:e8de089f95dd
       
     1 #include <relpipe/protocol/constants.h>
       
     2 
       
     3 #include "../include/relpipe/reader/TypeId.h"
       
     4 #include "../include/relpipe/reader/RelationalReader.h"
       
     5 #include "../include/relpipe/reader/Factory.h"
       
     6 #include "StreamRelationalReader.h"
       
     7 
       
     8 namespace relpipe {
       
     9 namespace reader {
       
    10 
       
    11 RelationalReader* Factory::create(std::istream& input) {
       
    12 	return new StreamRelationalReader(input);
       
    13 }
       
    14 
       
    15 /**
       
    16  * Some basic constants defined in lib-protocol are re-exported in public headers of lib-reader and lib-reader,
       
    17  * so we should check (during compile-time) that they match.
       
    18  */
       
    19 #define PROTOCOL_VIOLATION_TYPE_ID_ERROR "type id does not match with protocol"
       
    20 static_assert((int) TypeId::BOOLEAN == relpipe::protocol::DATA_TYPE_ID_BOOLEAN, PROTOCOL_VIOLATION_TYPE_ID_ERROR);
       
    21 static_assert((int) TypeId::STRING == relpipe::protocol::DATA_TYPE_ID_STRING, PROTOCOL_VIOLATION_TYPE_ID_ERROR);
       
    22 static_assert((int) TypeId::INTEGER == relpipe::protocol::DATA_TYPE_ID_INTEGER, PROTOCOL_VIOLATION_TYPE_ID_ERROR);
       
    23 
       
    24 #define PROTOCOL_VIOLATION_TYPE_DEF_ERROR "type definition does not match with protocol"
       
    25 static_assert(std::is_same<relpipe::reader::boolean_t, typename relpipe::protocol::boolean_t>::value, PROTOCOL_VIOLATION_TYPE_DEF_ERROR);
       
    26 static_assert(std::is_same<relpipe::reader::integer_t, typename relpipe::protocol::integer_t>::value, PROTOCOL_VIOLATION_TYPE_DEF_ERROR);
       
    27 static_assert(std::is_same<relpipe::reader::string_t, typename relpipe::protocol::string_t>::value, PROTOCOL_VIOLATION_TYPE_DEF_ERROR);
       
    28 static_assert(std::is_same<relpipe::reader::octet_t, typename relpipe::protocol::octet_t>::value, PROTOCOL_VIOLATION_TYPE_DEF_ERROR);
       
    29 
       
    30 }
       
    31 }