src/Configuration.h
branchv_0
changeset 0 c205f5d06418
child 2 362f2689cb87
equal deleted inserted replaced
-1:000000000000 0:c205f5d06418
       
     1 /**
       
     2  * Relational pipes
       
     3  * Copyright © 2019 František Kučera (Frantovo.cz, GlobalCode.info)
       
     4  *
       
     5  * This program is free software: you can redistribute it and/or modify
       
     6  * it under the terms of the GNU General Public License as published by
       
     7  * the Free Software Foundation, either version 3 of the License, or
       
     8  * (at your option) any later version.
       
     9  *
       
    10  * This program is distributed in the hope that it will be useful,
       
    11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
       
    12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
       
    13  * GNU General Public License for more details.
       
    14  *
       
    15  * You should have received a copy of the GNU General Public License
       
    16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
       
    17  */
       
    18 #pragma once
       
    19 
       
    20 #include <relpipe/writer/AttributeMetadata.h>
       
    21 #include <relpipe/writer/typedefs.h>
       
    22 
       
    23 namespace relpipe {
       
    24 namespace tr {
       
    25 namespace sql {
       
    26 
       
    27 class DefinitionRecipe {
       
    28 public:
       
    29 
       
    30 	virtual ~DefinitionRecipe() {
       
    31 	}
       
    32 
       
    33 	relpipe::writer::string_t name;
       
    34 	relpipe::writer::string_t type;
       
    35 	relpipe::writer::string_t value;
       
    36 };
       
    37 
       
    38 class RelationConfiguration {
       
    39 public:
       
    40 
       
    41 	virtual ~RelationConfiguration() {
       
    42 	}
       
    43 
       
    44 	relpipe::writer::string_t relation;
       
    45 	relpipe::writer::string_t sqlBeforeRecords;
       
    46 	relpipe::writer::string_t sqlAfterRecords;
       
    47 	relpipe::writer::string_t sqlForEach;
       
    48 
       
    49 	/**
       
    50 	 * If true, additional relation will be generated: mapping between relpipe attribute names and SQL variable names
       
    51 	 */
       
    52 	bool debugVariableMapping = false;
       
    53 
       
    54 	/**
       
    55 	 * If true, SQL code will be executed, but no output will be generated.
       
    56 	 */
       
    57 	bool drop = false;
       
    58 
       
    59 	/**
       
    60 	 * Variable definitions for this relation.
       
    61 	 * Can be used as a safe way for passing parameters from the outside environment.
       
    62 	 * See also Configuration::definitions (can be overridden by relation's definitions)
       
    63 	 */
       
    64 	std::vector<DefinitionRecipe> definitions;
       
    65 
       
    66 	/**
       
    67 	 * If empty, output relation will have same metadata as the input relation.
       
    68 	 */
       
    69 	std::vector<relpipe::writer::AttributeMetadata> writerMetadata;
       
    70 
       
    71 	/**
       
    72 	 * Whether original attributes should be appended to those specified using --output-attribute
       
    73 	 */
       
    74 	bool inputAttributesAppend = false;
       
    75 
       
    76 	/**
       
    77 	 * Whether original attributes should be prepended to those specified using --output-attribute
       
    78 	 */
       
    79 	bool inputAttributesPrepend = false;
       
    80 };
       
    81 
       
    82 class Configuration {
       
    83 public:
       
    84 
       
    85 	std::vector<RelationConfiguration> relationConfigurations;
       
    86 
       
    87 	/**
       
    88 	 * Global definitions for all relations.
       
    89 	 * Can be used as a safe way for passing parameters from the outside environment.
       
    90 	 * See also RelationConfiguration::definitions
       
    91 	 */
       
    92 	std::vector<DefinitionRecipe> definitions;
       
    93 
       
    94 	virtual ~Configuration() {
       
    95 	}
       
    96 };
       
    97 
       
    98 }
       
    99 }
       
   100 }