FlightGear
next
contacts.cxx
Go to the documentation of this file.
1
// -*- coding: utf-8 -*-
2
//
3
// contacts.cxx --- FlightGear classes holding add-on contact metadata
4
// Copyright (C) 2018 Florent Rougon
5
//
6
// This program is free software; you can redistribute it and/or modify
7
// it under the terms of the GNU General Public License as published by
8
// the Free Software Foundation; either version 2 of the License, or
9
// (at your option) any later version.
10
//
11
// This program is distributed in the hope that it will be useful,
12
// but WITHOUT ANY WARRANTY; without even the implied warranty of
13
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
// GNU General Public License for more details.
15
//
16
// You should have received a copy of the GNU General Public License along
17
// with this program; if not, write to the Free Software Foundation, Inc.,
18
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
20
#include <string>
21
#include <utility>
22
23
#include <simgear/nasal/cppbind/Ghost.hxx>
24
#include <simgear/nasal/cppbind/NasalHash.hxx>
25
#include <simgear/sg_inlines.h>
26
#include <simgear/structure/exception.hxx>
27
28
#include "
addon_fwd.hxx
"
29
#include "
contacts.hxx
"
30
31
using
std::string;
32
using
simgear::enumValue;
33
34
namespace
flightgear
35
{
36
37
namespace
addons
38
{
39
40
// ***************************************************************************
41
// * Contact *
42
// ***************************************************************************
43
44
Contact::Contact
(
ContactType
type,
string
name
,
string
email,
string
url)
45
: _type(type),
46
_name(std::move(
name
)),
47
_email(std::move(email)),
48
_url(std::move(url))
49
{ }
50
51
ContactType
Contact::getType
()
const
52
{
return
_type; }
53
54
string
Contact::getTypeString
()
const
55
{
56
switch
(
getType
()) {
57
case
ContactType::author
:
58
return
"author"
;
59
case
ContactType::maintainer
:
60
return
"maintainer"
;
61
default
:
62
throw
sg_error(
"unexpected value for member of "
63
"flightgear::addons::ContactType: "
+
64
std::to_string(enumValue(
getType
())));
65
}
66
}
67
68
string
Contact::getName
()
const
69
{
return
_name; }
70
71
void
Contact::setName
(
const
string
&
name
)
72
{ _name =
name
; }
73
74
string
Contact::getEmail
()
const
75
{
return
_email; }
76
77
void
Contact::setEmail
(
const
string
& email)
78
{ _email = email; }
79
80
string
Contact::getUrl
()
const
81
{
return
_url; }
82
83
void
Contact::setUrl
(
const
string
& url)
84
{ _url = url; }
85
86
// Static method
87
void
Contact::setupGhost
(nasal::Hash& addonsModule)
88
{
89
nasal::Ghost<ContactRef>::init(
"addons.Contact"
)
90
.member(
"name"
, &
Contact::getName
)
91
.member(
"email"
, &
Contact::getEmail
)
92
.member(
"url"
, &
Contact::getUrl
);
93
}
94
95
// ***************************************************************************
96
// * Author *
97
// ***************************************************************************
98
99
Author::Author
(
string
name
,
string
email,
string
url)
100
:
Contact
(
ContactType
::
author
,
name
, email, url)
101
{ }
102
103
// Static method
104
void
Author::setupGhost
(nasal::Hash& addonsModule)
105
{
106
nasal::Ghost<AuthorRef>::init(
"addons.Author"
)
107
.bases<
ContactRef
>();
108
}
109
110
// ***************************************************************************
111
// * Maintainer *
112
// ***************************************************************************
113
114
Maintainer::Maintainer
(
string
name
,
string
email,
string
url)
115
:
Contact
(
ContactType
::
maintainer
,
name
, email, url)
116
{ }
117
118
// Static method
119
void
Maintainer::setupGhost
(nasal::Hash& addonsModule)
120
{
121
nasal::Ghost<MaintainerRef>::init(
"addons.Maintainer"
)
122
.bases<
ContactRef
>();
123
}
124
125
}
// of namespace addons
126
127
}
// of namespace flightgear
addon_fwd.hxx
flightgear::addons::Author::setupGhost
static void setupGhost(nasal::Hash &addonsModule)
Definition
contacts.cxx:104
flightgear::addons::Author::Author
Author(std::string name, std::string email="", std::string url="")
Definition
contacts.cxx:99
flightgear::addons::Contact::setName
void setName(const std::string &name)
Definition
contacts.cxx:71
flightgear::addons::Contact::getName
std::string getName() const
Definition
contacts.cxx:68
flightgear::addons::Contact::setUrl
void setUrl(const std::string &url)
Definition
contacts.cxx:83
flightgear::addons::Contact::getEmail
std::string getEmail() const
Definition
contacts.cxx:74
flightgear::addons::Contact::Contact
Contact(ContactType type, std::string name, std::string email="", std::string url="")
Definition
contacts.cxx:44
flightgear::addons::Contact::getTypeString
std::string getTypeString() const
Definition
contacts.cxx:54
flightgear::addons::Contact::setEmail
void setEmail(const std::string &email)
Definition
contacts.cxx:77
flightgear::addons::Contact::getUrl
std::string getUrl() const
Definition
contacts.cxx:80
flightgear::addons::Contact::setupGhost
static void setupGhost(nasal::Hash &addonsModule)
Definition
contacts.cxx:87
flightgear::addons::Contact::getType
ContactType getType() const
Definition
contacts.cxx:51
flightgear::addons::Maintainer::setupGhost
static void setupGhost(nasal::Hash &addonsModule)
Definition
contacts.cxx:119
flightgear::addons::Maintainer::Maintainer
Maintainer(std::string name, std::string email="", std::string url="")
Definition
contacts.cxx:114
contacts.hxx
flightgear::addons
Definition
Addon.cxx:56
flightgear::addons::ContactType
ContactType
Definition
contacts.hxx:40
flightgear::addons::ContactType::author
@ author
Definition
contacts.hxx:41
flightgear::addons::ContactType::maintainer
@ maintainer
Definition
contacts.hxx:42
flightgear::addons::ContactRef
SGSharedPtr< Contact > ContactRef
Definition
addon_fwd.hxx:48
flightgear::addons::UrlType::author
@ author
Definition
Addon.hxx:46
flightgear::addons::UrlType::maintainer
@ maintainer
Definition
Addon.hxx:47
flightgear
FlightPlan.hxx - defines a full flight-plan object, including departure, cruise, arrival information ...
Definition
Addon.cxx:53
flightgear::name
const char * name
Definition
subsystemFactory.cxx:307
src
Add-ons
contacts.cxx
Generated on Tue Jun 3 2025 12:58:36 for FlightGear by
1.13.2