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.
This commit is contained in:
parent
d8a46cffa5
commit
b73dfb08ae
@ -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
|
||||
|
@ -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() {}
|
||||
|
@ -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<PropertyBasedElementPtr(SGPropertyNode*)>
|
||||
ElementFactory;
|
||||
|
||||
typedef boost::function<PropertyBasedElementPtr(SGPropertyNode*)>
|
||||
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<PropertyBasedElementPtr> _elements;
|
||||
|
||||
/** The actually managed elements */
|
||||
std::vector<PropertyBasedElementPtr> _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
|
||||
|
||||
|
@ -28,119 +28,115 @@
|
||||
|
||||
#include <list>
|
||||
|
||||
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<class T>
|
||||
void addInterpolatorFactory(const std::string& type)
|
||||
{
|
||||
addInterpolatorFactory
|
||||
(
|
||||
type,
|
||||
&simgear::make_new_derived<PropertyInterpolator, T>
|
||||
/**
|
||||
* Register factory for interpolation type.
|
||||
*/
|
||||
void addInterpolatorFactory(const std::string& type,
|
||||
InterpolatorFactory factory);
|
||||
template <class T>
|
||||
void addInterpolatorFactory(const std::string& type)
|
||||
{
|
||||
addInterpolatorFactory(
|
||||
type,
|
||||
&simgear::make_new_derived<PropertyInterpolator, T>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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<std::string, InterpolatorFactory> InterpolatorFactoryMap;
|
||||
typedef std::map<std::string, easing_func_t> EasingFunctionMap;
|
||||
typedef std::pair<SGPropertyNode*,
|
||||
PropertyInterpolatorRef> PropertyInterpolatorPair;
|
||||
typedef std::list<PropertyInterpolatorPair> InterpolatorList;
|
||||
|
||||
typedef std::map<std::string, InterpolatorFactory> InterpolatorFactoryMap;
|
||||
typedef std::map<std::string, easing_func_t> EasingFunctionMap;
|
||||
typedef std::pair< SGPropertyNode*,
|
||||
PropertyInterpolatorRef > PropertyInterpolatorPair;
|
||||
typedef std::list<PropertyInterpolatorPair> 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
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
|
@ -34,7 +34,6 @@ class SampleStatistic;
|
||||
|
||||
class SGPerformanceMonitor : public SGSubsystem
|
||||
{
|
||||
|
||||
public:
|
||||
SGPerformanceMonitor(SGSubsystemMgr* subSysMgr, SGPropertyNode_ptr root);
|
||||
|
||||
|
@ -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;
|
||||
};
|
||||
|
@ -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.</p>
|
||||
*/
|
||||
|
||||
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<class T>
|
||||
@ -431,6 +432,7 @@ public:
|
||||
{ return true; }
|
||||
|
||||
SGSubsystemMgr* get_manager() const override;
|
||||
|
||||
private:
|
||||
void forEach(std::function<void(SGSubsystem*)> f);
|
||||
void reverseForEach(std::function<void(SGSubsystem*)> f);
|
||||
@ -575,11 +577,11 @@ public:
|
||||
SOFT,
|
||||
PROPERTY
|
||||
};
|
||||
|
||||
|
||||
std::string name;
|
||||
Type type;
|
||||
};
|
||||
|
||||
|
||||
using DependencyVec = std::vector<SGSubsystemMgr::Dependency>;
|
||||
using SubsystemFactoryFunctor = std::function<SGSubsystemRef()>;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user