double min_step_sec)
{
Member * member = get_member(name, true);
- if (member->subsystem != 0)
- delete member->subsystem;
member->name = name;
member->subsystem = subsystem;
member->min_step_sec = min_step_sec;
SGSubsystemMgr::SGSubsystemMgr () :
+ _groups(MAX_GROUPS),
_initPosition(0)
{
- for (int i = 0; i < MAX_GROUPS; i++) {
- _groups[i] = new SGSubsystemGroup;
- }
+ for (int i = 0; i < MAX_GROUPS; i++)
+ _groups[i].reset(new SGSubsystemGroup);
}
SGSubsystemMgr::~SGSubsystemMgr ()
// ensure get_subsystem returns NULL from now onwards,
// before the SGSubsystemGroup destructors are run
_subsystem_map.clear();
-
- for (int i = 0; i < MAX_GROUPS; i++) {
- delete _groups[i];
- }
+ _groups.clear();
}
void
unsigned int _initPosition;
};
+typedef SGSharedPtr<SGSubsystemGroup> SGSubsystemGroupRef;
+
/**
* Manage subsystems for FlightGear.
*
void setReportTimingCb(void* userData,SGSubsystemTimingCb cb) {reportTimingCb = cb;reportTimingUserData = userData;}
private:
- SGSubsystemGroup* _groups[MAX_GROUPS];
+ std::vector<SGSubsystemGroupRef> _groups;
unsigned int _initPosition;
-
+
// non-owning reference
typedef std::map<std::string, SGSubsystem*> SubsystemDict;
SubsystemDict _subsystem_map;