diff --git a/include/rosa/core/SystemBase.hpp b/include/rosa/core/SystemBase.hpp index a076353..298b15c 100644 --- a/include/rosa/core/SystemBase.hpp +++ b/include/rosa/core/SystemBase.hpp @@ -1,80 +1,80 @@ /******************************************************************************* * * File: SystemBase.hpp * * Contents: Declaration of the base implementation of the System interface. * * Copyright 2017 * * Author: David Juhasz (david.juhasz@tuwien.ac.at) * ******************************************************************************/ #ifndef ROSA_CORE_SYSTEMBASE_HPP #define ROSA_CORE_SYSTEMBASE_HPP #include "rosa/core/System.hpp" #include namespace rosa { // Base implementation of the System interface, that provides only the name of // the System, identifiers for Units, and marking the System cleaned for // destruction. // NOTE: Actual implementations of the System and derived interfaces are // supposed to inherit from this base implementation. class SystemBase : public System { protected: // Protected ctor, only subclasses can instantiate. SystemBase(const std::string &Name) noexcept; public: // Dtor. // PRE: isSystemCleaned() ~SystemBase(void); protected: // The textual name of the System. const std::string Name; private: // Number of Units constructed in the system. // NOTE: Should never be decremented! - std::atomic CountUnits; + std::atomic UnitCount; // Indicates that the System has been cleaned and is ready for destruction. // The field is initialized as 'false' and can be set by the member function // markCleaned. // Subclasses must set the flag upon destroying the System instance, which // indicates to the destructor of the base-class that all the managed // resources has been properly released. - std::atomic SystemCleaned; + std::atomic SystemIsCleaned; public: // Returns a referene to the Name field. const std::string &name(void) const noexcept override; protected: // Tells the next Id to be used for a newly created Unit while - // incrementing the value in field CountUnits. - // NOTE: This is the only function modifying the member field CountUnits. + // incrementing the value in field UnitCount. + // NOTE: This is the only function modifying the member field UnitCount. id_t nextId(void) noexcept override; - // Returns the value of SystemCleaned flag. + // Returns the value of SystemIsCleaned flag. bool isSystemCleaned(void) const noexcept override; - // Sets SystemCleaned flag. + // Sets SystemIsCleaned flag. // PRE: !isSystemCleaned() && empty() // POST: isSystemCleaned void markCleaned(void) noexcept override; // Returns the number of Units constructed in the System so far, // including those being already destroyed. size_t numberOfConstructedUnits(void) const noexcept override; }; } // End namespace rosa #endif // ROSA_LIB_CORE_SYSTEMBASE_HPP diff --git a/lib/core/SystemBase.cpp b/lib/core/SystemBase.cpp index 17f8016..aa8aaac 100644 --- a/lib/core/SystemBase.cpp +++ b/lib/core/SystemBase.cpp @@ -1,59 +1,59 @@ /******************************************************************************* * * File: SystemBase.cpp * * Contents: Implementation of SystemBase. * * Copyright 2017 * * Author: David Juhasz (david.juhasz@tuwien.ac.at) * ******************************************************************************/ #include "rosa/core/SystemBase.hpp" namespace rosa { SystemBase::SystemBase(const std::string &Name) noexcept : Name(Name), - CountUnits(0), - SystemCleaned(false) { + UnitCount(0), + SystemIsCleaned(false) { LOG_TRACE("Creating System (" + Name + ")"); } SystemBase::~SystemBase(void) { - if (!SystemCleaned) { + if (!SystemIsCleaned) { ROSA_CRITICAL("Trying to destroy an uncleaned System (" + Name + ")"); } LOG_TRACE("Destroying System (" + Name + ")"); } const std::string &SystemBase::name() const noexcept { return Name; } id_t SystemBase::nextId(void) noexcept { - return ++CountUnits; + return ++UnitCount; } bool SystemBase::isSystemCleaned(void) const noexcept { - return SystemCleaned; + return SystemIsCleaned; } void SystemBase::markCleaned(void) noexcept { - if (SystemCleaned) { + if (SystemIsCleaned) { ROSA_CRITICAL("System (" + Name + ") has been already mark cleaned"); } else if (!empty()) { ROSA_CRITICAL("Trying to mark a non-empty System (" + Name + ")"); } else { - SystemCleaned = true; - LOG_TRACE("System (" + Name + ") is marked clean"); + SystemIsCleaned = true; + LOG_TRACE("System (" + Name + ") is marked cleaned"); } } size_t SystemBase::numberOfConstructedUnits(void) const noexcept { - return CountUnits; + return UnitCount; } } // End namespace rosa