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

ConfigDataBars class. More...

#include <ConfigDataBars.hpp>

Inheritance diagram for ConfigDataBars:
Inheritance graph
Collaboration diagram for ConfigDataBars:
Collaboration graph

Public Member Functions

 ConfigDataBars ()
 Construct a new ConfigDataBars object. More...
 
 ~ConfigDataBars () override
 Destroy the ConfigDataBars object. More...
 
void configInit (const Json::Value &root_) override
 Initialize the ConfigDataBars object You must call configInit() in each ConfigDataBase Child class to load the data. More...
 
Json::Value configSave () override
 return a Json::Value object containing the Bars configuration data More...
 
std::shared_ptr< ConfigDataBargetBar (int index)
 Get the Bar object at index. More...
 
void addBar (const std::string &barName, std::shared_ptr< ConfigDataBar > bar)
 Add a new Bar object to the ConfigDataBars object. More...
 
void removeBar (int index)
 Remove the Bar object at index. More...
 
const std::vector< std::shared_ptr< ConfigDataBar > > & getBars () const
 Get the Bars object. More...
 

Private Attributes

std::vector< std::shared_ptr< ConfigDataBar > > bars_
 

Detailed Description

Constructor & Destructor Documentation

◆ ConfigDataBars()

ConfigDataBars::ConfigDataBars ( )

Construct a new ConfigDataBars object.

32 : bars_() {}
std::vector< std::shared_ptr< ConfigDataBar > > bars_
Definition: ConfigDataBars.hpp:91

◆ ~ConfigDataBars()

ConfigDataBars::~ConfigDataBars ( )
override

Destroy the ConfigDataBars object.

54  {
55  bars_.clear();
56 }

References bars_.

Member Function Documentation

◆ addBar()

void ConfigDataBars::addBar ( const std::string &  barName,
std::shared_ptr< ConfigDataBar bar 
)

Add a new Bar object to the ConfigDataBars object.

50 { bars_.emplace_back(bar); }

References bars_.

◆ configInit()

void ConfigDataBars::configInit ( const Json::Value &  root_)
overridevirtual

Initialize the ConfigDataBars object You must call configInit() in each ConfigDataBase Child class to load the data.

Parameters
root_Json::Value& object containing the Bar configuration data
Todo:
use of a smart pointer to store the ConfigDataBar objects

Implements ConfigDataBase.

33  {
34  if (root.empty() || !root.isArray()) {
35  throw std::runtime_error("Invalid configuration file");
36  }
37  for (auto &bar : root) {
38  auto barData = std::make_shared<ConfigDataBar>();
39  barData->configInit(bar);
40  size_t newIndex = bars_.size();
41  bars_.emplace_back(barData);
42  Logger::GetInstance()->Log("=============================\t\tBar [" + std::to_string(newIndex) + "] Configuration loaded ✓",L_INFO);
43  }
44  Logger::GetInstance()->Log(std::to_string(bars_.size()) + " Bars configuration loaded [✓]",L_INFO);
45 }
@ 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 bars_, Logger::GetInstance(), L_INFO, and Logger::Log().

Here is the call graph for this function:

◆ configSave()

Json::Value ConfigDataBars::configSave ( )
overridevirtual

return a Json::Value object containing the Bars configuration data

Implements ConfigDataBase.

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

◆ getBar()

ConfigDataBar * ConfigDataBars::getBar ( int  index)

Get the Bar object at index.

Parameters
index
49 { return bars_[index]; }

References bars_.

◆ getBars()

const std::vector< ConfigDataBar * > & ConfigDataBars::getBars ( ) const

Get the Bars object.

52 { return bars_; }

References bars_.

◆ removeBar()

void ConfigDataBars::removeBar ( int  index)

Remove the Bar object at index.

Parameters
index
51 { bars_.erase(bars_.begin() + index);}

References bars_.

Member Data Documentation

◆ bars_

std::vector<std::shared_ptr<ConfigDataBar> > ConfigDataBars::bars_
private

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