Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Valentin Platzgummer
qgroundcontrol
Commits
3433b541
Commit
3433b541
authored
Oct 29, 2015
by
Don Gagne
Browse files
Remove as many Singletons as possible
Instead us a Toolbox concept which hangs off of QGCApplication
parent
ec1e8c2f
Changes
105
Hide whitespace changes
Inline
Side-by-side
QGCApplication.pro
View file @
3433b541
...
...
@@ -242,6 +242,7 @@ HEADERS += \
src
/
QGCQuickWidget
.
h
\
src
/
QGCSingleton
.
h
\
src
/
QGCTemporaryFile
.
h
\
src
/
QGCToolbox
.
h
\
src
/
QmlControls
/
CoordinateVector
.
h
\
src
/
QmlControls
/
MavlinkQmlSingleton
.
h
\
src
/
QmlControls
/
ParameterEditorController
.
h
\
...
...
@@ -356,6 +357,7 @@ SOURCES += \
src
/
QGCQuickWidget
.
cc
\
src
/
QGCSingleton
.
cc
\
src
/
QGCTemporaryFile
.
cc
\
src
/
QGCToolbox
.
cc
\
src
/
QGCGeo
.
cc
\
src
/
QmlControls
/
CoordinateVector
.
cc
\
src
/
QmlControls
/
ParameterEditorController
.
cc
\
...
...
src/AutoPilotPlugins/AutoPilotPlugin.cc
View file @
3433b541
...
...
@@ -101,7 +101,7 @@ bool AutoPilotPlugin::setupComplete(void)
void
AutoPilotPlugin
::
resetAllParametersToDefaults
(
void
)
{
mavlink_message_t
msg
;
MAVLinkProtocol
*
mavlink
=
MAVL
inkProtocol
::
instance
();
MAVLinkProtocol
*
mavlink
=
qgcApp
()
->
toolbox
()
->
mavl
inkProtocol
();
mavlink_msg_command_long_pack
(
mavlink
->
getSystemId
(),
mavlink
->
getComponentId
(),
&
msg
,
_vehicle
->
uas
()
->
getUASID
(),
0
,
MAV_CMD_PREFLIGHT_STORAGE
,
0
,
2
,
-
1
,
0
,
0
,
0
,
0
,
0
);
_vehicle
->
sendMessage
(
msg
);
...
...
src/AutoPilotPlugins/AutoPilotPluginManager.cc
View file @
3433b541
...
...
@@ -29,14 +29,6 @@
#include
"APM/APMAutoPilotPlugin.h"
#include
"Generic/GenericAutoPilotPlugin.h"
IMPLEMENT_QGC_SINGLETON
(
AutoPilotPluginManager
,
AutoPilotPluginManager
)
AutoPilotPluginManager
::
AutoPilotPluginManager
(
QObject
*
parent
)
:
QGCSingleton
(
parent
)
{
}
AutoPilotPlugin
*
AutoPilotPluginManager
::
newAutopilotPluginForVehicle
(
Vehicle
*
vehicle
)
{
switch
(
vehicle
->
firmwareType
())
{
...
...
src/AutoPilotPlugins/AutoPilotPluginManager.h
View file @
3433b541
...
...
@@ -32,23 +32,19 @@
#include
<QString>
#include
"AutoPilotPlugin.h"
#include
"QGCSingleton.h"
#include
"Vehicle.h"
#include
"QGCToolbox.h"
/// AutoPilotPlugin manager is a singleton which maintains the list of AutoPilotPlugin objects.
class
QGCApplication
;
class
AutoPilotPluginManager
:
public
QGC
Singleton
class
AutoPilotPluginManager
:
public
QGC
Tool
{
Q_OBJECT
DECLARE_QGC_SINGLETON
(
AutoPilotPluginManager
,
AutoPilotPluginManager
)
public:
AutoPilotPluginManager
(
QGCApplication
*
app
)
:
QGCTool
(
app
)
{
}
AutoPilotPlugin
*
newAutopilotPluginForVehicle
(
Vehicle
*
vehicle
);
private:
/// All access to singleton is through AutoPilotPluginManager::instance
AutoPilotPluginManager
(
QObject
*
parent
=
NULL
);
};
#endif
src/AutoPilotPlugins/PX4/AirframeComponentController.cc
View file @
3433b541
...
...
@@ -98,7 +98,7 @@ AirframeComponentController::~AirframeComponentController()
void
AirframeComponentController
::
changeAutostart
(
void
)
{
if
(
M
ultiVehicleManager
::
instance
()
->
vehicles
().
count
()
>
1
)
{
if
(
qgcApp
()
->
toolbox
()
->
m
ultiVehicleManager
()
->
vehicles
().
count
()
>
1
)
{
QGCMessageBox
::
warning
(
"Airframe Config"
,
"You cannot change airframe configuration while connected to multiple vehicles."
);
return
;
}
...
...
@@ -139,7 +139,7 @@ void AirframeComponentController::_rebootAfterStackUnwind(void)
QGC
::
SLEEP
::
usleep
(
500
);
qgcApp
()
->
processEvents
(
QEventLoop
::
ExcludeUserInputEvents
);
}
LinkManager
::
instance
()
->
disconnectAll
();
qgcApp
()
->
toolbox
()
->
linkManager
()
->
disconnectAll
();
qgcApp
()
->
restoreOverrideCursor
();
}
...
...
src/FactSystem/Fact.cc
View file @
3433b541
...
...
@@ -135,7 +135,6 @@ QString Fact::valueString(void) const
switch
(
type
())
{
case
FactMetaData
::
valueTypeFloat
:
qDebug
()
<<
name
()
<<
value
()
<<
decimalPlaces
();
valueString
=
QString
(
"%1"
).
arg
(
value
().
toFloat
(),
0
,
'g'
,
decimalPlaces
());
break
;
case
FactMetaData
::
valueTypeDouble
:
...
...
src/FactSystem/FactControls/FactPanelController.cc
View file @
3433b541
...
...
@@ -36,7 +36,7 @@ QGC_LOGGING_CATEGORY(FactPanelControllerLog, "FactPanelControllerLog")
FactPanelController
::
FactPanelController
(
void
)
:
_factPanel
(
NULL
)
{
_vehicle
=
M
ultiVehicleManager
::
instance
()
->
activeVehicle
();
_vehicle
=
qgcApp
()
->
toolbox
()
->
m
ultiVehicleManager
()
->
activeVehicle
();
Q_ASSERT
(
_vehicle
);
_uas
=
_vehicle
->
uas
();
...
...
src/FactSystem/FactSystem.cc
View file @
3433b541
...
...
@@ -29,19 +29,18 @@
#include
<QtQml>
IMPLEMENT_QGC_SINGLETON
(
FactSystem
,
FactSystem
)
const
char
*
FactSystem
::
_factSystemQmlUri
=
"QGroundControl.FactSystem"
;
FactSystem
::
FactSystem
(
Q
Object
*
parent
)
:
QGC
Singleton
(
parent
)
FactSystem
::
FactSystem
(
Q
GCApplication
*
app
)
:
QGC
Tool
(
app
)
{
qmlRegisterType
<
Fact
>
(
_factSystemQmlUri
,
1
,
0
,
"Fact"
);
qmlRegisterType
<
FactPanelController
>
(
_factSystemQmlUri
,
1
,
0
,
"FactPanelController"
);
}
FactSystem
::
~
FactSystem
(
)
void
FactSystem
::
setToolbox
(
QGCToolbox
*
toolbox
)
{
QGCTool
::
setToolbox
(
toolbox
);
qmlRegisterType
<
Fact
>
(
_factSystemQmlUri
,
1
,
0
,
"Fact"
);
qmlRegisterType
<
FactPanelController
>
(
_factSystemQmlUri
,
1
,
0
,
"FactPanelController"
);
}
src/FactSystem/FactSystem.h
View file @
3433b541
...
...
@@ -29,10 +29,8 @@
#include
"Fact.h"
#include
"FactMetaData.h"
#include
"QGC
Singleton
.h"
#include
"QGC
Toolbox
.h"
/// FactSystem is a singleton which provides access to the Facts in the system
///
/// The components of the FactSystem are a Fact which holds an individual value. FactMetaData holds
/// additional meta data associated with a Fact such as description, min/max ranges and so forth.
/// The FactValidator object is a QML validator which validates input according to the FactMetaData
...
...
@@ -40,13 +38,17 @@
/// of this is the PX4ParameterMetaData onbject which is part of the PX4 AutoPilot plugin. It exposes
/// the firmware parameters to QML such that you can bind QML ui elements directly to parameters.
class
FactSystem
:
public
QGC
Singleton
class
FactSystem
:
public
QGC
Tool
{
Q_OBJECT
DECLARE_QGC_SINGLETON
(
FactSystem
,
FactSystem
)
public:
/// All access to FactSystem is through FactSystem::instance, so constructor is private
FactSystem
(
QGCApplication
*
app
);
// Override from QGCTool
virtual
void
setToolbox
(
QGCToolbox
*
toolbox
);
typedef
enum
{
ParameterProvider
,
}
Provider_t
;
...
...
@@ -54,10 +56,6 @@ public:
static
const
int
defaultComponentId
=
-
1
;
private:
/// All access to FactSystem is through FactSystem::instance, so constructor is private
FactSystem
(
QObject
*
parent
=
NULL
);
~
FactSystem
();
static
const
char
*
_factSystemQmlUri
;
///< URI for FactSystem QML imports
};
...
...
src/FactSystem/FactSystemTestBase.cc
View file @
3433b541
...
...
@@ -44,19 +44,9 @@ void FactSystemTestBase::_init(MAV_AUTOPILOT autopilot)
{
UnitTest
::
init
();
MockLink
*
link
=
new
MockLink
();
link
->
setFirmwareType
(
autopilot
);
LinkManager
::
instance
()
->
_addLink
(
link
);
_connectMockLink
(
autopilot
);
LinkManager
::
instance
()
->
connectLink
(
link
);
// Wait for the Vehicle to get created
QSignalSpy
spyVehicle
(
MultiVehicleManager
::
instance
(),
SIGNAL
(
parameterReadyVehicleAvailableChanged
(
bool
)));
QCOMPARE
(
spyVehicle
.
wait
(
5000
),
true
);
QVERIFY
(
MultiVehicleManager
::
instance
()
->
parameterReadyVehicleAvailable
());
QVERIFY
(
MultiVehicleManager
::
instance
()
->
activeVehicle
());
_plugin
=
MultiVehicleManager
::
instance
()
->
activeVehicle
()
->
autopilotPlugin
();
_plugin
=
qgcApp
()
->
toolbox
()
->
multiVehicleManager
()
->
activeVehicle
()
->
autopilotPlugin
();
Q_ASSERT
(
_plugin
);
}
...
...
src/FactSystem/ParameterLoader.cc
View file @
3433b541
...
...
@@ -50,7 +50,7 @@ ParameterLoader::ParameterLoader(AutoPilotPlugin* autopilot, Vehicle* vehicle, Q
QObject
(
parent
),
_autopilot
(
autopilot
),
_vehicle
(
vehicle
),
_mavlink
(
MAVL
inkProtocol
::
instance
()),
_mavlink
(
qgcApp
()
->
toolbox
()
->
mavl
inkProtocol
()),
_parametersReady
(
false
),
_initialLoadComplete
(
false
),
_defaultComponentId
(
FactSystem
::
defaultComponentId
),
...
...
@@ -308,7 +308,7 @@ void ParameterLoader::refreshAllParameters(void)
_dataMutex
.
unlock
();
MAVLinkProtocol
*
mavlink
=
MAVL
inkProtocol
::
instance
();
MAVLinkProtocol
*
mavlink
=
qgcApp
()
->
toolbox
()
->
mavl
inkProtocol
();
Q_ASSERT
(
mavlink
);
mavlink_message_t
msg
;
...
...
@@ -501,7 +501,7 @@ void ParameterLoader::_tryCacheLookup()
/* Start waiting for 2.5 seconds to get a cache hit and avoid loading all params over the radio */
_cacheTimeoutTimer
.
start
();
MAVLinkProtocol
*
mavlink
=
MAVL
inkProtocol
::
instance
();
MAVLinkProtocol
*
mavlink
=
qgcApp
()
->
toolbox
()
->
mavl
inkProtocol
();
Q_ASSERT
(
mavlink
);
mavlink_message_t
msg
;
...
...
@@ -825,7 +825,7 @@ void ParameterLoader::_checkInitialLoadComplete(void)
// Check for any errors during vehicle boot
UASMessageHandler
*
msgHandler
=
UAS
MessageHandler
::
instance
();
UASMessageHandler
*
msgHandler
=
qgcApp
()
->
toolbox
()
->
uas
MessageHandler
();
if
(
msgHandler
->
getErrorCountTotal
())
{
QString
errors
;
bool
firstError
=
true
;
...
...
src/FirmwarePlugin/APM/APMFirmwarePlugin.cc
View file @
3433b541
...
...
@@ -139,8 +139,7 @@ QString APMCustomMode::modeString() const
return
mode
;
}
APMFirmwarePlugin
::
APMFirmwarePlugin
(
QObject
*
parent
)
:
FirmwarePlugin
(
parent
)
APMFirmwarePlugin
::
APMFirmwarePlugin
(
void
)
{
_textSeverityAdjustmentNeeded
=
false
;
}
...
...
src/FirmwarePlugin/APM/APMFirmwarePlugin.h
View file @
3433b541
...
...
@@ -94,7 +94,7 @@ public:
protected:
/// All access to singleton is through stack specific implementation
APMFirmwarePlugin
(
QObject
*
parent
=
NULL
);
APMFirmwarePlugin
(
void
);
void
setSupportedModes
(
QList
<
APMCustomMode
>
supportedModes
);
private:
...
...
src/FirmwarePlugin/APM/ArduCopterFirmwarePlugin.cc
View file @
3433b541
...
...
@@ -53,8 +53,7 @@ APMCopterMode::APMCopterMode(uint32_t mode, bool settable) : APMCustomMode(mode,
setEnumToStringMapping
(
enumToString
);
}
ArduCopterFirmwarePlugin
::
ArduCopterFirmwarePlugin
(
QObject
*
parent
)
:
APMFirmwarePlugin
(
parent
)
ArduCopterFirmwarePlugin
::
ArduCopterFirmwarePlugin
(
void
)
{
QList
<
APMCustomMode
>
supportedFlightModes
;
supportedFlightModes
<<
APMCopterMode
(
APMCopterMode
::
STABILIZE
,
true
);
...
...
src/FirmwarePlugin/APM/ArduCopterFirmwarePlugin.h
View file @
3433b541
...
...
@@ -68,7 +68,7 @@ public:
protected:
/// All access to singleton is through instance()
ArduCopterFirmwarePlugin
(
QObject
*
parent
=
NULL
);
ArduCopterFirmwarePlugin
(
void
);
private:
};
...
...
src/FirmwarePlugin/APM/ArduPlaneFirmwarePlugin.cc
View file @
3433b541
...
...
@@ -50,8 +50,7 @@ APMPlaneMode::APMPlaneMode(uint32_t mode, bool settable) : APMCustomMode(mode, s
setEnumToStringMapping
(
enumToString
);
}
ArduPlaneFirmwarePlugin
::
ArduPlaneFirmwarePlugin
(
QObject
*
parent
)
:
APMFirmwarePlugin
(
parent
)
ArduPlaneFirmwarePlugin
::
ArduPlaneFirmwarePlugin
(
void
)
{
QList
<
APMCustomMode
>
supportedFlightModes
;
supportedFlightModes
<<
APMPlaneMode
(
APMPlaneMode
::
MANUAL
,
true
);
...
...
src/FirmwarePlugin/APM/ArduPlaneFirmwarePlugin.h
View file @
3433b541
...
...
@@ -66,7 +66,7 @@ public:
protected:
/// All access to singleton is through instance()
ArduPlaneFirmwarePlugin
(
QObject
*
parent
=
NULL
);
ArduPlaneFirmwarePlugin
(
void
);
private:
};
...
...
src/FirmwarePlugin/APM/ArduRoverFirmwarePlugin.cc
View file @
3433b541
...
...
@@ -44,8 +44,7 @@ APMRoverMode::APMRoverMode(uint32_t mode, bool settable) : APMCustomMode(mode, s
setEnumToStringMapping
(
enumToString
);
}
ArduRoverFirmwarePlugin
::
ArduRoverFirmwarePlugin
(
QObject
*
parent
)
:
APMFirmwarePlugin
(
parent
)
ArduRoverFirmwarePlugin
::
ArduRoverFirmwarePlugin
(
void
)
{
QList
<
APMCustomMode
>
supportedFlightModes
;
supportedFlightModes
<<
APMRoverMode
(
APMRoverMode
::
MANUAL
,
true
);
...
...
src/FirmwarePlugin/APM/ArduRoverFirmwarePlugin.h
View file @
3433b541
...
...
@@ -66,7 +66,7 @@ public:
protected:
/// All access to singleton is through instance()
ArduRoverFirmwarePlugin
(
QObject
*
parent
=
NULL
);
ArduRoverFirmwarePlugin
(
void
);
private:
};
...
...
src/FirmwarePlugin/FirmwarePlugin.h
View file @
3433b541
...
...
@@ -112,7 +112,7 @@ public:
virtual
void
addMetaDataToFact
(
Fact
*
fact
)
=
0
;
protected:
FirmwarePlugin
(
QObject
*
parent
=
NULL
)
:
QGCSingleton
(
parent
)
{
}
FirmwarePlugin
(
void
)
{
}
;
};
#endif
Prev
1
2
3
4
5
6
Next
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment