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

ConfigDataGroup class Store the configuration for a group from the config file. the logic of groups is handled by the Group class the logic of the layout of a group is handled in a sub class of LayoutManager class e.g. TreeLayoutManager. More...

#include <ConfigDataGroup.hpp>

Inheritance diagram for ConfigDataGroup:
Inheritance graph
Collaboration diagram for ConfigDataGroup:
Collaboration graph

Public Member Functions

 ConfigDataGroup ()
 
 ~ConfigDataGroup () override=default
 
void configInit (const Json::Value &root) override
 Initialize the configuration for a group from the config file. must be called after instanciating the object. Parse the Json::Value root and store the values in the object. More...
 
Json::Value configSave () override
 Build a Json::Value object with the configuration. More...
 
const std::string & getGroupName () const
 
const std::string & getGroupLayout () const
 
unsigned long getGroupInactiveColor () const
 
unsigned long getGroupActiveColor () const
 
int getGroupBorderWidth () const
 
int getGroupGap () const
 

Private Attributes

std::string groupName_
 
std::string groupLayout_
 
unsigned long groupInactiveColor_ {}
 
unsigned long groupActiveColor_ {}
 
int groupBorderSize_ {}
 
int groupGap_ {}
 

Detailed Description

ConfigDataGroup class Store the configuration for a group from the config file. the logic of groups is handled by the Group class the logic of the layout of a group is handled in a sub class of LayoutManager class e.g. TreeLayoutManager.

Constructor & Destructor Documentation

◆ ConfigDataGroup()

ConfigDataGroup::ConfigDataGroup ( )
33  {
34  groupName_ = "Default";
35  groupLayout_ = "Tree";
36  groupInactiveColor_ = 0x00ff00;
37  groupActiveColor_ = 0x00ff00;
38  groupBorderSize_ = 0;
39  groupGap_ = 10;
40 }
int groupBorderSize_
Definition: ConfigDataGroup.hpp:65
unsigned long groupActiveColor_
Definition: ConfigDataGroup.hpp:64
std::string groupName_
Definition: ConfigDataGroup.hpp:61
unsigned long groupInactiveColor_
Definition: ConfigDataGroup.hpp:63
std::string groupLayout_
Definition: ConfigDataGroup.hpp:62
int groupGap_
Definition: ConfigDataGroup.hpp:66

References groupActiveColor_, groupBorderSize_, groupGap_, groupInactiveColor_, groupLayout_, and groupName_.

◆ ~ConfigDataGroup()

ConfigDataGroup::~ConfigDataGroup ( )
overridedefault

Member Function Documentation

◆ configInit()

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

Initialize the configuration for a group from the config file. must be called after instanciating the object. Parse the Json::Value root and store the values in the object.

Parameters
root

Implements ConfigDataBase.

41  {
42  if (root.empty() || !root.isObject()) {
43  throw std::runtime_error("ConfigDataGroup::configInit root is empty or not an object");
44  }
45  if (root["Name"].empty() || !root["Name"].isString()) {
46  Logger::GetInstance()->Log("ConfigDataGroup::configInit Name is empty or not a string",L_ERROR);
47  } else {
48  groupName_ = root["Name"].asString();
49  }
50  if (root["Layout"].empty() || !root["Layout"].isString()) {
51  Logger::GetInstance()->Log("ConfigDataGroup::configInit Layout is empty or not a string",L_ERROR);
52  } else {
53  groupLayout_ = root["Layout"].asString();
54  }
55  if (root["Inactive_Color"].empty() || !root["Inactive_Color"].isString()) {
56  Logger::GetInstance()->Log("ConfigDataGroup::configInit Inactive_Color is empty or not a string",L_ERROR);
57  } else
58  {
59  groupInactiveColor_ = ConfigHandler::colorCodeToULong(root["Inactive_Color"].asString());
60  }
61  if (root["Active_Color"].empty() || !root["Active_Color"].isString()) {
62  Logger::GetInstance()->Log("ConfigDataGroup::configInit Active_Color is empty or not a string",L_ERROR);
63  } else
64  {
65  groupActiveColor_ = ConfigHandler::colorCodeToULong(root["Active_Color"].asString());
66  }
67  if (root["Border_Size"].empty() || !root["Border_Size"].isInt()) {
68  Logger::GetInstance()->Log("ConfigDataGroup::configInit Border_Size is empty or not an int",L_ERROR);
69  } else {
70  groupBorderSize_ = root["Border_Size"].asInt();
71  }
72  if (root["Gap"].empty() || !root["Gap"].isInt()) {
73  Logger::GetInstance()->Log("ConfigDataGroup::configInit Gap is empty or not an int",L_ERROR);
74  } else {
75  groupGap_ = root["Gap"].asInt();
76  }
77  std::ostringstream msg;
78  msg << "Group[" << groupName_ << "]"
79  << "\tLayout [" << groupLayout_ << "]"
80  << "\tInactive_Color [#" << std::hex << std::setw(6) << std::setfill('0') << groupInactiveColor_ << std::dec << "]"
81  << "\tActive_Color [#" << std::hex << std::setw(6) << std::setfill('0') << groupActiveColor_ << std::dec << "]"
82  << "\tBorder_Size [" << groupBorderSize_ << "]"
83  << "\tGap [" << groupGap_ << "]"
84  << "-> loaded\t\t[✓]";
85  Logger::GetInstance()->Log(msg.str(),L_INFO);
86 
87 }
@ L_ERROR
Definition: Logger.hpp:51
@ L_INFO
Definition: Logger.hpp:49
static unsigned long colorCodeToULong(const std::string &colorCode)
Convert a string containing a color code to unsigned long.
Definition: ConfigHandler.cpp:94
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 ConfigHandler::colorCodeToULong(), Logger::GetInstance(), groupActiveColor_, groupBorderSize_, groupGap_, groupInactiveColor_, groupLayout_, groupName_, L_ERROR, L_INFO, and Logger::Log().

Here is the call graph for this function:

◆ configSave()

Json::Value ConfigDataGroup::configSave ( )
overridevirtual

Build a Json::Value object with the configuration.

Returns
Json::Value Object with the current runtime configuration

Implements ConfigDataBase.

88  {
89  return Json::Value();
90 }

◆ getGroupActiveColor()

unsigned long ConfigDataGroup::getGroupActiveColor ( ) const
94 { return groupActiveColor_; }

References groupActiveColor_.

◆ getGroupBorderWidth()

int ConfigDataGroup::getGroupBorderWidth ( ) const
95 { return groupBorderSize_; }

References groupBorderSize_.

◆ getGroupGap()

int ConfigDataGroup::getGroupGap ( ) const
96 { return groupGap_; }

References groupGap_.

◆ getGroupInactiveColor()

unsigned long ConfigDataGroup::getGroupInactiveColor ( ) const
93 { return groupInactiveColor_; }

References groupInactiveColor_.

◆ getGroupLayout()

const std::string & ConfigDataGroup::getGroupLayout ( ) const
92 { return groupLayout_; }

References groupLayout_.

◆ getGroupName()

const std::string & ConfigDataGroup::getGroupName ( ) const
91 { return groupName_; }

References groupName_.

Member Data Documentation

◆ groupActiveColor_

unsigned long ConfigDataGroup::groupActiveColor_ {}
private

◆ groupBorderSize_

int ConfigDataGroup::groupBorderSize_ {}
private

◆ groupGap_

int ConfigDataGroup::groupGap_ {}
private

◆ groupInactiveColor_

unsigned long ConfigDataGroup::groupInactiveColor_ {}
private

◆ groupLayout_

std::string ConfigDataGroup::groupLayout_
private

◆ groupName_

std::string ConfigDataGroup::groupName_
private

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