GDAL
gdal_relationship.h
1/******************************************************************************
2 *
3 * Project: GDAL
4 * Purpose: Declaration of GDALRelationship class
5 * Author: Nyall Dawson, <nyall dot dawson at gmail dot com>
6 *
7 ******************************************************************************
8 * Copyright (c) 2022, Nyall Dawson <nyall dot dawson at gmail dot comg>
9 *
10 * SPDX-License-Identifier: MIT
11 ****************************************************************************/
12
13#ifndef GDALRELATIONSHIP_H_INCLUDED
14#define GDALRELATIONSHIP_H_INCLUDED
15
16#include "cpl_port.h"
17#include "gdal.h"
18
19#include <string>
20#include <vector>
21
22/************************************************************************/
23/* Relationships */
24/************************************************************************/
25
37class CPL_DLL GDALRelationship
38{
39 protected:
41 std::string m_osName{};
42 std::string m_osLeftTableName{};
43 std::string m_osRightTableName{};
44 GDALRelationshipCardinality m_eCardinality =
46 std::string m_osMappingTableName{};
47 std::vector<std::string> m_osListLeftTableFields{};
48 std::vector<std::string> m_osListRightTableFields{};
49 std::vector<std::string> m_osListLeftMappingTableFields{};
50 std::vector<std::string> m_osListRightMappingTableFields{};
52 std::string m_osForwardPathLabel{};
53 std::string m_osBackwardPathLabel{};
54 std::string m_osRelatedTableType{};
55
58 public:
66 GDALRelationship(const std::string &osName,
67 const std::string &osLeftTableName,
68 const std::string &osRightTableName,
69 GDALRelationshipCardinality eCardinality =
71 : m_osName(osName), m_osLeftTableName(osLeftTableName),
72 m_osRightTableName(osRightTableName), m_eCardinality(eCardinality)
73 {
74 }
75
77 const std::string &GetName() const
78 {
79 return m_osName;
80 }
81
84 {
85 return m_eCardinality;
86 }
87
93 const std::string &GetLeftTableName() const
94 {
95 return m_osLeftTableName;
96 }
97
103 void SetLeftTableName(const std::string &osName)
104 {
105 m_osLeftTableName = osName;
106 }
107
114 const std::string &GetRightTableName() const
115 {
116 return m_osRightTableName;
117 }
118
125 void SetRightTableName(const std::string &osName)
126 {
127 m_osRightTableName = osName;
128 }
129
134 const std::string &GetMappingTableName() const
135 {
136 return m_osMappingTableName;
137 }
138
143 void SetMappingTableName(const std::string &osName)
144 {
145 m_osMappingTableName = osName;
146 }
147
154 const std::vector<std::string> &GetLeftTableFields() const
155 {
156 return m_osListLeftTableFields;
157 }
158
165 const std::vector<std::string> &GetRightTableFields() const
166 {
167 return m_osListRightTableFields;
168 }
169
176 void SetLeftTableFields(const std::vector<std::string> &osListFields)
177 {
178 m_osListLeftTableFields = osListFields;
179 }
180
187 void SetRightTableFields(const std::vector<std::string> &osListFields)
188 {
189 m_osListRightTableFields = osListFields;
190 }
191
198 const std::vector<std::string> &GetLeftMappingTableFields() const
199 {
200 return m_osListLeftMappingTableFields;
201 }
202
209 const std::vector<std::string> &GetRightMappingTableFields() const
210 {
211 return m_osListRightMappingTableFields;
212 }
213
220 void SetLeftMappingTableFields(const std::vector<std::string> &osListFields)
221 {
222 m_osListLeftMappingTableFields = osListFields;
223 }
224
231 void
232 SetRightMappingTableFields(const std::vector<std::string> &osListFields)
233 {
234 m_osListRightMappingTableFields = osListFields;
235 }
236
242 {
243 return m_eType;
244 }
245
251 {
252 m_eType = eType;
253 }
254
270 const std::string &GetForwardPathLabel() const
271 {
272 return m_osForwardPathLabel;
273 }
274
290 void SetForwardPathLabel(const std::string &osLabel)
291 {
292 m_osForwardPathLabel = osLabel;
293 }
294
310 const std::string &GetBackwardPathLabel() const
311 {
312 return m_osBackwardPathLabel;
313 }
314
330 void SetBackwardPathLabel(const std::string &osLabel)
331 {
332 m_osBackwardPathLabel = osLabel;
333 }
334
345 const std::string &GetRelatedTableType() const
346 {
347 return m_osRelatedTableType;
348 }
349
360 void SetRelatedTableType(const std::string &osType)
361 {
362 m_osRelatedTableType = osType;
363 }
364
367 static inline GDALRelationshipH ToHandle(GDALRelationship *poRelationship)
368 {
369 return static_cast<GDALRelationshipH>(poRelationship);
370 }
371
374 static inline GDALRelationship *FromHandle(GDALRelationshipH hRelationship)
375 {
376 return static_cast<GDALRelationship *>(hRelationship);
377 }
378};
379
380#endif
Definition of a table relationship.
Definition gdal_relationship.h:38
const std::string & GetName() const
Get the name of the relationship.
Definition gdal_relationship.h:77
const std::vector< std::string > & GetLeftMappingTableFields() const
Get the names of the mapping table fields which correspond to the participating fields from the left ...
Definition gdal_relationship.h:198
void SetType(GDALRelationshipType eType)
Sets the type of the relationship.
Definition gdal_relationship.h:250
void SetLeftMappingTableFields(const std::vector< std::string > &osListFields)
Sets the names of the mapping table fields which correspond to the participating fields from the left...
Definition gdal_relationship.h:220
void SetMappingTableName(const std::string &osName)
Sets the name of the mapping table for many-to-many relationships.
Definition gdal_relationship.h:143
static GDALRelationshipH ToHandle(GDALRelationship *poRelationship)
Convert a GDALRelationship* to a GDALRelationshipH.
Definition gdal_relationship.h:367
const std::string & GetForwardPathLabel() const
Get the label of the forward path for the relationship.
Definition gdal_relationship.h:270
const std::string & GetLeftTableName() const
Get the name of the left (or base/origin) table in the relationship.
Definition gdal_relationship.h:93
void SetLeftTableName(const std::string &osName)
Sets the name of the left (or base/origin) table in the relationship.
Definition gdal_relationship.h:103
const std::string & GetBackwardPathLabel() const
Get the label of the backward path for the relationship.
Definition gdal_relationship.h:310
const std::string & GetRelatedTableType() const
Get the type string of the related table.
Definition gdal_relationship.h:345
const std::string & GetMappingTableName() const
Get the name of the mapping table for many-to-many relationships.
Definition gdal_relationship.h:134
void SetLeftTableFields(const std::vector< std::string > &osListFields)
Sets the names of the participating fields from the left table in the relationship.
Definition gdal_relationship.h:176
GDALRelationshipCardinality GetCardinality() const
Get the cardinality of the relationship.
Definition gdal_relationship.h:83
void SetRightTableFields(const std::vector< std::string > &osListFields)
Sets the names of the participating fields from the right table in the relationship.
Definition gdal_relationship.h:187
void SetForwardPathLabel(const std::string &osLabel)
Sets the label of the forward path for the relationship.
Definition gdal_relationship.h:290
void SetBackwardPathLabel(const std::string &osLabel)
Sets the label of the backward path for the relationship.
Definition gdal_relationship.h:330
const std::vector< std::string > & GetRightTableFields() const
Get the names of the participating fields from the right table in the relationship.
Definition gdal_relationship.h:165
void SetRightMappingTableFields(const std::vector< std::string > &osListFields)
Sets the names of the mapping table fields which correspond to the participating fields from the righ...
Definition gdal_relationship.h:232
static GDALRelationship * FromHandle(GDALRelationshipH hRelationship)
Convert a GDALRelationshipH to a GDALRelationship*.
Definition gdal_relationship.h:374
const std::vector< std::string > & GetRightMappingTableFields() const
Get the names of the mapping table fields which correspond to the participating fields from the right...
Definition gdal_relationship.h:209
GDALRelationship(const std::string &osName, const std::string &osLeftTableName, const std::string &osRightTableName, GDALRelationshipCardinality eCardinality=GDALRelationshipCardinality::GRC_ONE_TO_MANY)
Constructor for a relationship between two tables.
Definition gdal_relationship.h:66
GDALRelationshipType GetType() const
Get the type of the relationship.
Definition gdal_relationship.h:241
void SetRightTableName(const std::string &osName)
Sets the name of the right (or related/destination) table in the relationship.
Definition gdal_relationship.h:125
const std::vector< std::string > & GetLeftTableFields() const
Get the names of the participating fields from the left table in the relationship.
Definition gdal_relationship.h:154
const std::string & GetRightTableName() const
Get the name of the right (or related/destination) table in the relationship.
Definition gdal_relationship.h:114
void SetRelatedTableType(const std::string &osType)
Sets the type string of the related table.
Definition gdal_relationship.h:360
Core portability definitions for CPL.
Public (C callable) GDAL entry points.
GDALRelationshipCardinality
Cardinality of relationship.
Definition gdal.h:2481
@ GRC_ONE_TO_MANY
One-to-many.
Definition gdal.h:2485
GDALRelationshipType
Type of relationship.
Definition gdal.h:2497
@ GRT_ASSOCIATION
Association relationship.
Definition gdal.h:2501
void * GDALRelationshipH
Opaque type used for the C bindings of the C++ GDALRelationship class.
Definition gdal_fwd.h:66