Add getter for an Application's list of Subsystems

This commit is contained in:
Scott Davis
2015-01-08 15:16:56 -05:00
parent d992509f6e
commit 240128b640
2 changed files with 41 additions and 33 deletions

View File

@@ -86,6 +86,8 @@ class Util_API Application: public Subsystem
{
public:
typedef std::vector<std::string> ArgVec;
typedef Poco::AutoPtr<Subsystem> SubsystemPtr;
typedef std::vector<SubsystemPtr> SubsystemVec;
enum ExitCode
/// Commonly used exit status codes.
@@ -218,6 +220,9 @@ public:
/// Throws a NotFoundException if such a subsystem has
/// not been registered.
SubsystemVec& subsystems();
/// Returns a reference to the subsystem list
virtual int run();
/// Runs the application by performing additional (un)initializations
/// and calling the main() method.
@@ -367,8 +372,6 @@ private:
void processOptions();
bool findAppConfigFile(const std::string& appName, const std::string& extension, Poco::Path& path) const;
typedef Poco::AutoPtr<Subsystem> SubsystemPtr;
typedef std::vector<SubsystemPtr> SubsystemVec;
typedef Poco::AutoPtr<LayeredConfiguration> ConfigPtr;
ConfigPtr _pConfig;
@@ -410,6 +413,11 @@ template <class C> C& Application::getSubsystem() const
throw Poco::NotFoundException("The subsystem has not been registered", typeid(C).name());
}
inline Application::SubsystemVec& Application::subsystems()
{
return _subsystems;
}
inline bool Application::initialized() const
{

View File

@@ -53,11 +53,11 @@ public:
Subsystem();
/// Creates the Subsystem.
protected:
virtual const char* name() const = 0;
/// Returns the name of the subsystem.
/// Must be implemented by subclasses.
protected:
virtual void initialize(Application& app) = 0;
/// Initializes the subsystem.