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