From b73dfb08aefa745e72885af27c66b93eafb9f8e5 Mon Sep 17 00:00:00 2001
From: Edward d'Auvergne
Date: Tue, 3 Apr 2018 11:59:46 +0200
Subject: [PATCH] SGSubsystem classes: Whitespace standardisation of the
declarations.
This is a clean up commit prior to the subsystem API standardisation to simplify
the diffs. It includes all SGSubsystem and SGSubsystemGroup derived classes.
---
simgear/canvas/CanvasMgr.hxx | 61 ++++---
simgear/misc/interpolator.hxx | 3 +-
simgear/props/PropertyBasedMgr.hxx | 105 ++++++-----
simgear/props/PropertyInterpolationMgr.hxx | 192 ++++++++++-----------
simgear/scene/tsync/terrasync.hxx | 2 +-
simgear/sound/soundmgr.hxx | 4 +-
simgear/structure/SGPerfMon.hxx | 1 -
simgear/structure/event_mgr.hxx | 23 ++-
simgear/structure/subsystem_mgr.hxx | 30 ++--
9 files changed, 209 insertions(+), 212 deletions(-)
diff --git a/simgear/canvas/CanvasMgr.hxx b/simgear/canvas/CanvasMgr.hxx
index 3255d4bc..e689a7f4 100644
--- a/simgear/canvas/CanvasMgr.hxx
+++ b/simgear/canvas/CanvasMgr.hxx
@@ -28,42 +28,39 @@ namespace simgear
namespace canvas
{
- class CanvasMgr:
- public PropertyBasedMgr
- {
- public:
+class CanvasMgr : public PropertyBasedMgr
+{
+public:
+ /**
+ * @param node Root node of branch used to control canvasses
+ */
+ CanvasMgr(SGPropertyNode_ptr node);
- /**
- * @param node Root node of branch used to control canvasses
- */
- CanvasMgr(SGPropertyNode_ptr node);
+ /**
+ * Create a new canvas
+ *
+ * @param name Name of the new canvas
+ */
+ CanvasPtr createCanvas(const std::string& name = "");
- /**
- * Create a new canvas
- *
- * @param name Name of the new canvas
- */
- CanvasPtr createCanvas(const std::string& name = "");
+ /**
+ * Get ::Canvas by index
+ *
+ * @param index Index of texture node in /canvas/by-index/
+ */
+ CanvasPtr getCanvas(size_t index) const;
- /**
- * Get ::Canvas by index
- *
- * @param index Index of texture node in /canvas/by-index/
- */
- CanvasPtr getCanvas(size_t index) const;
+ /**
+ * Get ::Canvas by name
+ *
+ * @param name Value of child node "name" in
+ * /canvas/by-index/texture[i]/name
+ */
+ CanvasPtr getCanvas(const std::string& name) const;
- /**
- * Get ::Canvas by name
- *
- * @param name Value of child node "name" in
- * /canvas/by-index/texture[i]/name
- */
- CanvasPtr getCanvas(const std::string& name) const;
-
- protected:
-
- void elementCreated(PropertyBasedElementPtr element) override;
- };
+protected:
+ void elementCreated(PropertyBasedElementPtr element) override;
+};
} // namespace canvas
} // namespace simgear
diff --git a/simgear/misc/interpolator.hxx b/simgear/misc/interpolator.hxx
index e0721c6c..9a5bdcfa 100644
--- a/simgear/misc/interpolator.hxx
+++ b/simgear/misc/interpolator.hxx
@@ -30,7 +30,8 @@
// code can register another one immediately without worrying about
// timer aliasing.
-class SGInterpolator : public SGSubsystem {
+class SGInterpolator : public SGSubsystem
+{
public:
SGInterpolator() { _list = 0; }
virtual void init() {}
diff --git a/simgear/props/PropertyBasedMgr.hxx b/simgear/props/PropertyBasedMgr.hxx
index 9a14dab5..e058206b 100644
--- a/simgear/props/PropertyBasedMgr.hxx
+++ b/simgear/props/PropertyBasedMgr.hxx
@@ -29,74 +29,71 @@
namespace simgear
{
- class PropertyBasedMgr:
- public SGSubsystem,
- public SGPropertyChangeListener
- {
- public:
- void init() override;
- void shutdown() override;
+class PropertyBasedMgr : public SGSubsystem,
+ public SGPropertyChangeListener
+{
+public:
+ void init() override;
+ void shutdown() override;
- void update (double delta_time_sec) override;
+ void update(double delta_time_sec) override;
- /**
- * Create a new PropertyBasedElement
- *
- * @param name Name of the new element
- */
- PropertyBasedElementPtr createElement(const std::string& name = "");
+ /**
+ * Create a new PropertyBasedElement
+ *
+ * @param name Name of the new element
+ */
+ PropertyBasedElementPtr createElement(const std::string& name = "");
- /**
- * Get an existing PropertyBasedElement by its index
- *
- * @param index Index of element node in property tree
- */
- PropertyBasedElementPtr getElement(size_t index) const;
+ /**
+ * Get an existing PropertyBasedElement by its index
+ *
+ * @param index Index of element node in property tree
+ */
+ PropertyBasedElementPtr getElement(size_t index) const;
- /**
- * Get an existing PropertyBasedElement by its name
- *
- * @param name Name (value of child node "name" will be matched)
- */
- PropertyBasedElementPtr getElement(const std::string& name) const;
+ /**
+ * Get an existing PropertyBasedElement by its name
+ *
+ * @param name Name (value of child node "name" will be matched)
+ */
+ PropertyBasedElementPtr getElement(const std::string& name) const;
- virtual const SGPropertyNode* getPropertyRoot() const;
+ virtual const SGPropertyNode* getPropertyRoot() const;
- protected:
+protected:
+ typedef boost::function
+ ElementFactory;
- typedef boost::function
- ElementFactory;
+ /** Branch in the property tree for this property managed subsystem */
+ SGPropertyNode_ptr _props;
- /** Branch in the property tree for this property managed subsystem */
- SGPropertyNode_ptr _props;
+ /** Property name of managed elements */
+ const std::string _name_elements;
- /** Property name of managed elements */
- const std::string _name_elements;
+ /** The actually managed elements */
+ std::vector _elements;
- /** The actually managed elements */
- std::vector _elements;
+ /** Function object which creates a new element */
+ ElementFactory _element_factory;
- /** Function object which creates a new element */
- ElementFactory _element_factory;
+ /**
+ * @param props Root node of property branch used for controlling
+ * this subsystem
+ * @param name_elements The name of the nodes for the managed elements
+ */
+ PropertyBasedMgr( SGPropertyNode_ptr props,
+ const std::string& name_elements,
+ ElementFactory element_factory );
+ virtual ~PropertyBasedMgr() = 0;
- /**
- * @param props Root node of property branch used for controlling
- * this subsystem
- * @param name_elements The name of the nodes for the managed elements
- */
- PropertyBasedMgr( SGPropertyNode_ptr props,
- const std::string& name_elements,
- ElementFactory element_factory );
- virtual ~PropertyBasedMgr() = 0;
-
- void childAdded( SGPropertyNode * parent,
+ void childAdded( SGPropertyNode * parent,
+ SGPropertyNode * child ) override;
+ void childRemoved( SGPropertyNode * parent,
SGPropertyNode * child ) override;
- void childRemoved( SGPropertyNode * parent,
- SGPropertyNode * child ) override;
- virtual void elementCreated(PropertyBasedElementPtr element) {}
-
- };
+ virtual void elementCreated(PropertyBasedElementPtr element) {}
+};
} // namespace simgear
diff --git a/simgear/props/PropertyInterpolationMgr.hxx b/simgear/props/PropertyInterpolationMgr.hxx
index efd907d9..51ec15d7 100644
--- a/simgear/props/PropertyInterpolationMgr.hxx
+++ b/simgear/props/PropertyInterpolationMgr.hxx
@@ -28,119 +28,115 @@
#include
-namespace simgear
+namespace simgear {
+
+/**
+ * Subsystem that manages interpolation of properties.
+ *
+ * By default the numeric values of the properties are interpolated. For
+ * example, for strings this is probably not the wanted behavior. For this
+ * adapter classes can be registered to allow providing specific
+ * interpolations for certain types of properties. Using the type "color",
+ * provided by ColorInterpolator, strings containing %CSS colors can also be
+ * interpolated.
+ *
+ * Additionally different functions can be used for easing of the animation.
+ * By default "linear" (constant animation speed) and "swing" (smooth
+ * acceleration and deceleration) are available.
+ */
+class PropertyInterpolationMgr : public SGSubsystem
{
+public:
+ typedef PropertyInterpolator* (*InterpolatorFactory)();
- /**
- * Subsystem that manages interpolation of properties.
- *
- * By default the numeric values of the properties are interpolated. For
- * example, for strings this is probably not the wanted behavior. For this
- * adapter classes can be registered to allow providing specific
- * interpolations for certain types of properties. Using the type "color",
- * provided by ColorInterpolator, strings containing %CSS colors can also be
- * interpolated.
- *
- * Additionally different functions can be used for easing of the animation.
- * By default "linear" (constant animation speed) and "swing" (smooth
- * acceleration and deceleration) are available.
- */
- class PropertyInterpolationMgr:
- public SGSubsystem
- {
- public:
- typedef PropertyInterpolator* (*InterpolatorFactory)();
+ PropertyInterpolationMgr();
- PropertyInterpolationMgr();
+ /**
+ * Update all active interpolators.
+ */
+ void update(double dt);
- /**
- * Update all active interpolators.
- */
- void update(double dt);
+ /**
+ * Create a new property interpolator.
+ *
+ * @note To actually use it the interpolator needs to be attached to a
+ * property using PropertyInterpolationMgr::interpolate.
+ *
+ * @param type Type of animation ("numeric", "color", etc.)
+ * @param target Property containing target value
+ * @param duration Duration if the animation (in seconds)
+ * @param easing Type of easing ("linear", "swing", etc.)
+ */
+ PropertyInterpolator*
+ createInterpolator(const std::string& type,
+ const SGPropertyNode& target,
+ double duration,
+ const std::string& easing);
- /**
- * Create a new property interpolator.
- *
- * @note To actually use it the interpolator needs to be attached to a
- * property using PropertyInterpolationMgr::interpolate.
- *
- * @param type Type of animation ("numeric", "color", etc.)
- * @param target Property containing target value
- * @param duration Duration if the animation (in seconds)
- * @param easing Type of easing ("linear", "swing", etc.)
- */
- PropertyInterpolator*
- createInterpolator( const std::string& type,
- const SGPropertyNode& target,
- double duration,
- const std::string& easing );
+ /**
+ * Add animation of the given property from its current value to the
+ * target value of the interpolator. If no interpolator is given any
+ * existing animation of the given property is aborted.
+ *
+ * @param prop Property to be interpolated
+ * @param interp Interpolator used for interpolation
+ */
+ bool interpolate(SGPropertyNode* prop,
+ PropertyInterpolatorRef interp = 0);
- /**
- * Add animation of the given property from its current value to the
- * target value of the interpolator. If no interpolator is given any
- * existing animation of the given property is aborted.
- *
- * @param prop Property to be interpolated
- * @param interp Interpolator used for interpolation
- */
- bool interpolate( SGPropertyNode* prop,
- PropertyInterpolatorRef interp = 0 );
+ bool interpolate(SGPropertyNode* prop,
+ const std::string& type,
+ const SGPropertyNode& target,
+ double duration,
+ const std::string& easing);
- bool interpolate( SGPropertyNode* prop,
- const std::string& type,
- const SGPropertyNode& target,
- double duration,
- const std::string& easing );
+ bool interpolate(SGPropertyNode* prop,
+ const std::string& type,
+ const PropertyList& values,
+ const double_list& deltas,
+ const std::string& easing);
- bool interpolate( SGPropertyNode* prop,
- const std::string& type,
- const PropertyList& values,
- const double_list& deltas,
- const std::string& easing );
-
- /**
- * Register factory for interpolation type.
- */
- void addInterpolatorFactory( const std::string& type,
- InterpolatorFactory factory );
- template
- void addInterpolatorFactory(const std::string& type)
- {
- addInterpolatorFactory
- (
- type,
- &simgear::make_new_derived
+ /**
+ * Register factory for interpolation type.
+ */
+ void addInterpolatorFactory(const std::string& type,
+ InterpolatorFactory factory);
+ template
+ void addInterpolatorFactory(const std::string& type)
+ {
+ addInterpolatorFactory(
+ type,
+ &simgear::make_new_derived
);
- }
+ }
- /**
- * Register easing function.
- */
- void addEasingFunction(const std::string& type, easing_func_t func);
+ /**
+ * Register easing function.
+ */
+ void addEasingFunction(const std::string& type, easing_func_t func);
- /**
- * Set property containing real time delta (not sim time)
- *
- * TODO better pass both deltas to all update methods...
- */
- void setRealtimeProperty(SGPropertyNode* node);
+ /**
+ * Set property containing real time delta (not sim time)
+ *
+ * TODO better pass both deltas to all update methods...
+ */
+ void setRealtimeProperty(SGPropertyNode* node);
- protected:
+protected:
+ typedef std::map InterpolatorFactoryMap;
+ typedef std::map EasingFunctionMap;
+ typedef std::pair PropertyInterpolatorPair;
+ typedef std::list InterpolatorList;
- typedef std::map InterpolatorFactoryMap;
- typedef std::map EasingFunctionMap;
- typedef std::pair< SGPropertyNode*,
- PropertyInterpolatorRef > PropertyInterpolatorPair;
- typedef std::list InterpolatorList;
+ struct PredicateIsSameProp;
- struct PredicateIsSameProp;
+ InterpolatorFactoryMap _interpolator_factories;
+ EasingFunctionMap _easing_functions;
+ InterpolatorList _interpolators;
- InterpolatorFactoryMap _interpolator_factories;
- EasingFunctionMap _easing_functions;
- InterpolatorList _interpolators;
-
- SGPropertyNode_ptr _rt_prop;
- };
+ SGPropertyNode_ptr _rt_prop;
+};
} // namespace simgear
diff --git a/simgear/scene/tsync/terrasync.hxx b/simgear/scene/tsync/terrasync.hxx
index 4e806568..214fdf5a 100644
--- a/simgear/scene/tsync/terrasync.hxx
+++ b/simgear/scene/tsync/terrasync.hxx
@@ -39,7 +39,6 @@ class BufferedLogCallback;
class SGTerraSync : public SGSubsystem
{
public:
-
SGTerraSync();
virtual ~SGTerraSync();
@@ -80,6 +79,7 @@ public:
void scheduleDataDir(const std::string& dataDir);
bool isDataDirPending(const std::string& dataDir) const;
+
protected:
void syncAirportsModels();
string_list getSceneryPathSuffixes() const;
diff --git a/simgear/sound/soundmgr.hxx b/simgear/sound/soundmgr.hxx
index 89b8cda4..55e683de 100644
--- a/simgear/sound/soundmgr.hxx
+++ b/simgear/sound/soundmgr.hxx
@@ -49,7 +49,6 @@ class SGSoundSample;
class SGSoundMgr : public SGSubsystem
{
public:
-
SGSoundMgr();
~SGSoundMgr();
@@ -310,7 +309,7 @@ public:
size_t *size,
int *freq,
int *block );
-
+
/**
* Get a list of available playback devices.
*/
@@ -325,6 +324,7 @@ public:
bool testForError(std::string s, std::string name = "sound manager");
static const char* subsystemName() { return "sound"; };
+
private:
class SoundManagerPrivate;
/// private implementation object
diff --git a/simgear/structure/SGPerfMon.hxx b/simgear/structure/SGPerfMon.hxx
index 32d642cc..683beb46 100644
--- a/simgear/structure/SGPerfMon.hxx
+++ b/simgear/structure/SGPerfMon.hxx
@@ -34,7 +34,6 @@ class SampleStatistic;
class SGPerformanceMonitor : public SGSubsystem
{
-
public:
SGPerformanceMonitor(SGSubsystemMgr* subSysMgr, SGPropertyNode_ptr root);
diff --git a/simgear/structure/event_mgr.hxx b/simgear/structure/event_mgr.hxx
index 70d516fb..ea79abcb 100644
--- a/simgear/structure/event_mgr.hxx
+++ b/simgear/structure/event_mgr.hxx
@@ -8,11 +8,12 @@
class SGEventMgr;
-class SGTimer {
+class SGTimer
+{
public:
~SGTimer();
void run();
-
+
std::string name;
double interval;
SGCallback* callback;
@@ -20,7 +21,8 @@ public:
bool running;
};
-class SGTimerQueue {
+class SGTimerQueue
+{
public:
SGTimerQueue(int preSize=1);
~SGTimerQueue();
@@ -37,8 +39,9 @@ public:
double nextTime() { return -_table[0].pri; }
SGTimer* findByName(const std::string& name) const;
-
+
void dump();
+
private:
// The "priority" is stored as a negative time. This allows the
// implementation to treat the "top" of the heap as the largest
@@ -50,9 +53,9 @@ private:
int rchild(int n) { return ((n+1)*2 + 1) - 1; }
double pri(int n) { return _table[n].pri; }
void swap(int a, int b) {
- HeapEntry tmp = _table[a];
- _table[a] = _table[b];
- _table[b] = tmp;
+ HeapEntry tmp = _table[a];
+ _table[a] = _table[b];
+ _table[b] = tmp;
}
void siftDown(int n);
void siftUp(int n);
@@ -77,6 +80,7 @@ public:
virtual void update(double delta_time_sec);
virtual void unbind();
virtual void shutdown();
+
void setRealtimeProperty(SGPropertyNode* node) { _rtProp = node; }
/**
@@ -119,8 +123,9 @@ public:
void removeTask(const std::string& name);
-
+
void dump();
+
private:
friend class SGTimer;
@@ -130,7 +135,7 @@ private:
SGPropertyNode_ptr _freezeProp;
SGPropertyNode_ptr _rtProp;
- SGTimerQueue _rtQueue;
+ SGTimerQueue _rtQueue;
SGTimerQueue _simQueue;
bool _inited, _shutdown;
};
diff --git a/simgear/structure/subsystem_mgr.hxx b/simgear/structure/subsystem_mgr.hxx
index b991a9ef..76b88327 100644
--- a/simgear/structure/subsystem_mgr.hxx
+++ b/simgear/structure/subsystem_mgr.hxx
@@ -127,6 +127,7 @@ typedef void (*SGSubsystemTimingCb)(void* userData, const std::string& name, Sam
* subsystems may also override the suspend() and resume() methods to
* take different actions.
*/
+
class SGSubsystem : public SGReferenced
{
public:
@@ -342,24 +343,24 @@ public:
protected:
friend class SGSubsystemMgr;
friend class SGSubsystemGroup;
-
+
void set_name(const std::string& n);
void set_group(SGSubsystemGroup* group);
-
+
/// composite name for the subsystem (type name and instance name if this
/// is an instanced subsystem. (Since this member was originally defined as
/// protected, not private, we can't rename it easily)
std::string _name;
-
- bool _suspended = false;
- eventTimeVec timingInfo;
+ bool _suspended = false;
- static SGSubsystemTimingCb reportTimingCb;
- static void* reportTimingUserData;
- static bool reportTimingStatsRequest;
- static int maxTimePerFrame_ms;
+ eventTimeVec timingInfo;
+
+ static SGSubsystemTimingCb reportTimingCb;
+ static void* reportTimingUserData;
+ static bool reportTimingStatsRequest;
+ static int maxTimePerFrame_ms;
private:
SGSubsystemGroup* _group = nullptr;
@@ -416,9 +417,9 @@ public:
*/
void set_fixed_update_time(double fixed_dt);
- /**
- * retrive list of member subsystem names
- */
+ /**
+ * retrive list of member subsystem names
+ */
string_list member_names() const;
template
@@ -431,6 +432,7 @@ public:
{ return true; }
SGSubsystemMgr* get_manager() const override;
+
private:
void forEach(std::function f);
void reverseForEach(std::function f);
@@ -575,11 +577,11 @@ public:
SOFT,
PROPERTY
};
-
+
std::string name;
Type type;
};
-
+
using DependencyVec = std::vector;
using SubsystemFactoryFunctor = std::function;