YggdrasilWM  0.1.1
A tiny window manager coded in C++
ConfigDataGroups Class Reference

ConfigDataGroups class. stores an array of ConfigDataGroup created from the config file. More...

#include <ConfigDataGroups.hpp>

Inheritance diagram for ConfigDataGroups:
Inheritance graph
Collaboration diagram for ConfigDataGroups:
Collaboration graph

Public Member Functions

 ConfigDataGroups ()
 
 ~ConfigDataGroups () override
 
void configInit (const Json::Value &root) override
 Must be called after instanciation to load the config file. Parses the json root and creates ConfigDataGroup objects. More...
 
Json::Value configSave () override
 Build a Json::Value object with the configuration. More...
 
void addGroup (std::shared_ptr< ConfigDataGroup > group)
 
void removeGroup (ConfigDataGroup *group)
 
std::shared_ptr< ConfigDataGroupgetGroup (int index)
 
const std::vector< std::shared_ptr< ConfigDataGroup > > & getGroups () const
 

Private Attributes

std::vector< std::shared_ptr< ConfigDataGroup > > groups_
 

Detailed Description

ConfigDataGroups class. stores an array of ConfigDataGroup created from the config file.

Constructor & Destructor Documentation

◆ ConfigDataGroups()

ConfigDataGroups::ConfigDataGroups ( )
32 : groups_() {}
std::vector< std::shared_ptr< ConfigDataGroup > > groups_
Definition: ConfigDataGroups.hpp:59

◆ ~ConfigDataGroups()

ConfigDataGroups::~ConfigDataGroups ( )
override
59  {
60  groups_.clear();
61 }

References groups_.

Member Function Documentation

◆ addGroup()

void ConfigDataGroups::addGroup ( std::shared_ptr< ConfigDataGroup group)
49 { groups_.push_back(group); }

References groups_.

◆ configInit()

void ConfigDataGroups::configInit ( const Json::Value &  root)
overridevirtual

Must be called after instanciation to load the config file. Parses the json root and creates ConfigDataGroup objects.

Parameters
root

Implements ConfigDataBase.

33  {
34  if (root.empty() || !root.isArray()) {
35  throw std::runtime_error("Invalid configuration file");
36  }
37  for (auto &group : root) {
38  auto group_ = std::make_shared<ConfigDataGroup>();
39  group_->configInit(group);
40  groups_.push_back(group_);
41  Logger::GetInstance()->Log("=============================\t\tGroup [" + group_->getGroupName() + "] Configuration loaded ✓",L_INFO);
42  }
43  Logger::GetInstance()->Log(std::to_string(groups_.size()) + " Groups configuration loaded [✓]",L_INFO);
44 }
@ L_INFO
Definition: Logger.hpp:49
virtual void Log(const std::string &message, LogLevel level) const
Log a message This method logs a message to the log file or stream. The message is only logged if the...
Definition: Logger.cpp:73
static Logger * GetInstance()
Get the Logger object.
Definition: Logger.cpp:41

References Logger::GetInstance(), groups_, L_INFO, and Logger::Log().

Here is the call graph for this function:

◆ configSave()

Json::Value ConfigDataGroups::configSave ( )
overridevirtual

Build a Json::Value object with the configuration.

Returns
Json::Value Object with the current runtime configuration

Implements ConfigDataBase.

45  {
46  return Json::Value();
47 }

◆ getGroup()

std::shared_ptr< ConfigDataGroup > ConfigDataGroups::getGroup ( int  index)
48 { return groups_[index]; }

References groups_.

◆ getGroups()

const std::vector< std::shared_ptr< ConfigDataGroup > > & ConfigDataGroups::getGroups ( ) const
58 { return groups_;}

References groups_.

◆ removeGroup()

void ConfigDataGroups::removeGroup ( ConfigDataGroup group)
50  {
51  for (auto it = groups_.begin(); it != groups_.end(); ++it) {
52  if (it->get() == group) {
53  groups_.erase(it);
54  break;
55  }
56  }
57 }

References groups_.

Member Data Documentation

◆ groups_

std::vector<std::shared_ptr<ConfigDataGroup> > ConfigDataGroups::groups_
private

The documentation for this class was generated from the following files: