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
37 class 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 =
45 GDALRelationshipCardinality::GRC_ONE_TO_MANY;
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{};
51 GDALRelationshipType m_eType = GDALRelationshipType::GRT_ASSOCIATION;
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 =
70 GDALRelationshipCardinality::GRC_ONE_TO_MANY)
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
83 GDALRelationshipCardinality GetCardinality() const
84 {
85 return m_eCardinality;
86 }
87
92 const std::string &GetLeftTableName() const
93 {
94 return m_osLeftTableName;
95 }
96
99 const std::string &GetRightTableName() const
100 {
101 return m_osRightTableName;
102 }
103
108 const std::string &GetMappingTableName() const
109 {
110 return m_osMappingTableName;
111 }
112
117 void SetMappingTableName(const std::string &osName)
118 {
119 m_osMappingTableName = osName;
120 }
121
128 const std::vector<std::string> &GetLeftTableFields() const
129 {
130 return m_osListLeftTableFields;
131 }
132
139 const std::vector<std::string> &GetRightTableFields() const
140 {
141 return m_osListRightTableFields;
142 }
143
150 void SetLeftTableFields(const std::vector<std::string> &osListFields)
151 {
152 m_osListLeftTableFields = osListFields;
153 }
154
161 void SetRightTableFields(const std::vector<std::string> &osListFields)
162 {
163 m_osListRightTableFields = osListFields;
164 }
165
172 const std::vector<std::string> &GetLeftMappingTableFields() const
173 {
174 return m_osListLeftMappingTableFields;
175 }
176
183 const std::vector<std::string> &GetRightMappingTableFields() const
184 {
185 return m_osListRightMappingTableFields;
186 }
187
194 void SetLeftMappingTableFields(const std::vector<std::string> &osListFields)
195 {
196 m_osListLeftMappingTableFields = osListFields;
197 }
198
205 void
206 SetRightMappingTableFields(const std::vector<std::string> &osListFields)
207 {
208 m_osListRightMappingTableFields = osListFields;
209 }
210
215 GDALRelationshipType GetType() const
216 {
217 return m_eType;
218 }
219
224 void SetType(GDALRelationshipType eType)
225 {
226 m_eType = eType;
227 }
228
244 const std::string &GetForwardPathLabel() const
245 {
246 return m_osForwardPathLabel;
247 }
248
264 void SetForwardPathLabel(const std::string &osLabel)
265 {
266 m_osForwardPathLabel = osLabel;
267 }
268
284 const std::string &GetBackwardPathLabel() const
285 {
286 return m_osBackwardPathLabel;
287 }
288
304 void SetBackwardPathLabel(const std::string &osLabel)
305 {
306 m_osBackwardPathLabel = osLabel;
307 }
308
319 const std::string &GetRelatedTableType() const
320 {
321 return m_osRelatedTableType;
322 }
323
334 void SetRelatedTableType(const std::string &osType)
335 {
336 m_osRelatedTableType = osType;
337 }
338
341 static inline GDALRelationshipH ToHandle(GDALRelationship *poRelationship)
342 {
343 return static_cast<GDALRelationshipH>(poRelationship);
344 }
345
348 static inline GDALRelationship *FromHandle(GDALRelationshipH hRelationship)
349 {
350 return static_cast<GDALRelationship *>(hRelationship);
351 }
352};
353
354#endif
GDALRelationship
Definition of a table relationship.
Definition gdal_relationship.h:38
GDALRelationship::GetName
const std::string & GetName() const
Get the name of the relationship.
Definition gdal_relationship.h:77
GDALRelationship::GetLeftMappingTableFields
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:172
GDALRelationship::SetType
void SetType(GDALRelationshipType eType)
Sets the type of the relationship.
Definition gdal_relationship.h:224
GDALRelationship::SetLeftMappingTableFields
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:194
GDALRelationship::SetMappingTableName
void SetMappingTableName(const std::string &osName)
Sets the name of the mapping table for many-to-many relationships.
Definition gdal_relationship.h:117
GDALRelationship::ToHandle
static GDALRelationshipH ToHandle(GDALRelationship *poRelationship)
Convert a GDALRelationship* to a GDALRelationshipH.
Definition gdal_relationship.h:341
GDALRelationship::GetForwardPathLabel
const std::string & GetForwardPathLabel() const
Get the label of the forward path for the relationship.
Definition gdal_relationship.h:244
GDALRelationship::GetLeftTableName
const std::string & GetLeftTableName() const
Get the name of the left (or base/origin) table in the relationship.
Definition gdal_relationship.h:92
GDALRelationship::GetBackwardPathLabel
const std::string & GetBackwardPathLabel() const
Get the label of the backward path for the relationship.
Definition gdal_relationship.h:284
GDALRelationship::GetRelatedTableType
const std::string & GetRelatedTableType() const
Get the type string of the related table.
Definition gdal_relationship.h:319
GDALRelationship::GetMappingTableName
const std::string & GetMappingTableName() const
Get the name of the mapping table for many-to-many relationships.
Definition gdal_relationship.h:108
GDALRelationship::SetLeftTableFields
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:150
GDALRelationship::GetCardinality
GDALRelationshipCardinality GetCardinality() const
Get the cardinality of the relationship.
Definition gdal_relationship.h:83
GDALRelationship::SetRightTableFields
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:161
GDALRelationship::SetForwardPathLabel
void SetForwardPathLabel(const std::string &osLabel)
Sets the label of the forward path for the relationship.
Definition gdal_relationship.h:264
GDALRelationship::SetBackwardPathLabel
void SetBackwardPathLabel(const std::string &osLabel)
Sets the label of the backward path for the relationship.
Definition gdal_relationship.h:304
GDALRelationship::GetRightTableFields
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:139
GDALRelationship::SetRightMappingTableFields
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:206
GDALRelationship::FromHandle
static GDALRelationship * FromHandle(GDALRelationshipH hRelationship)
Convert a GDALRelationshipH to a GDALRelationship*.
Definition gdal_relationship.h:348
GDALRelationship::GetRightMappingTableFields
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:183
GDALRelationship::GDALRelationship
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
GDALRelationship::GetType
GDALRelationshipType GetType() const
Get the type of the relationship.
Definition gdal_relationship.h:215
GDALRelationship::GetLeftTableFields
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:128
GDALRelationship::GetRightTableName
const std::string & GetRightTableName() const
Get the name of the right (or related/destination) table in the relationship.
Definition gdal_relationship.h:99
GDALRelationship::SetRelatedTableType
void SetRelatedTableType(const std::string &osType)
Sets the type string of the related table.
Definition gdal_relationship.h:334
cpl_port.h
Core portability definitions for CPL.
gdal.h
Public (C callable) GDAL entry points.
GDALRelationshipCardinality
GDALRelationshipCardinality
Cardinality of relationship.
Definition gdal.h:2423
GRC_ONE_TO_MANY
@ GRC_ONE_TO_MANY
One-to-many.
Definition gdal.h:2427
GDALRelationshipType
GDALRelationshipType
Type of relationship.
Definition gdal.h:2439
GRT_ASSOCIATION
@ GRT_ASSOCIATION
Association relationship.
Definition gdal.h:2443
GDALRelationshipH
void * GDALRelationshipH
Opaque type used for the C bindings of the C++ GDALRelationship class.
Definition gdal_fwd.h:66