src/Configuration.h
branchv_0
changeset 2 362f2689cb87
parent 0 c205f5d06418
child 5 cbc7817a3346
equal deleted inserted replaced
1:eb7134dfdcc5 2:362f2689cb87
    22 
    22 
    23 namespace relpipe {
    23 namespace relpipe {
    24 namespace tr {
    24 namespace tr {
    25 namespace sql {
    25 namespace sql {
    26 
    26 
    27 class DefinitionRecipe {
    27 class Parameter {
    28 public:
    28 public:
    29 
    29 
    30 	virtual ~DefinitionRecipe() {
    30 	relpipe::writer::string_t value;
       
    31 	// TODO: relpipe::writer::TypeId type;
       
    32 };
       
    33 
       
    34 class Statement {
       
    35 public:
       
    36 
       
    37 	virtual ~Statement() {
    31 	}
    38 	}
    32 
    39 
    33 	relpipe::writer::string_t name;
    40 	/**
    34 	relpipe::writer::string_t type;
    41 	 * output relation name;
    35 	relpipe::writer::string_t value;
    42 	 * if empty, the SQL code (DML, DDL) will be executed, but no relational output will be generated
    36 };
    43 	 */
    37 
       
    38 class RelationConfiguration {
       
    39 public:
       
    40 
       
    41 	virtual ~RelationConfiguration() {
       
    42 	}
       
    43 
       
    44 	relpipe::writer::string_t relation;
    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 	/**
    45 	/**
    50 	 * If true, additional relation will be generated: mapping between relpipe attribute names and SQL variable names
    46 	 * SQL code, usually some SELECT;
       
    47 	 * might be also DML or DDL
    51 	 */
    48 	 */
    52 	bool debugVariableMapping = false;
    49 	relpipe::writer::string_t sql;
    53 
    50 	std::vector<Parameter> parameters;
    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 };
    51 };
    81 
    52 
    82 class Configuration {
    53 class Configuration {
    83 public:
    54 public:
    84 
    55 
    85 	std::vector<RelationConfiguration> relationConfigurations;
    56 	std::vector<Statement> statements;
    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 
    57 
    94 	virtual ~Configuration() {
    58 	virtual ~Configuration() {
    95 	}
    59 	}
    96 };
    60 };
    97 
    61