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

#include <ConfigDataWidget.hpp>

Inheritance diagram for ConfigDataWidget:
Inheritance graph
Collaboration diagram for ConfigDataWidget:
Collaboration graph

Public Member Functions

 ConfigDataWidget ()
 
 ~ConfigDataWidget () override=default
 
void configInit (const Json::Value &root) override
 Initialize the configuration. More...
 
Json::Value configSave () override
 Build a Json::Value object with the configuration. More...
 
const std::string & getType () const
 
const std::string & getPluginLocation () const
 
const std::string & getFontName () const
 
int getFontSize () const
 
int getBorderSize () const
 
unsigned long getBorderColor () const
 
int getPosition () const
 
int getSize () const
 
unsigned long getFgColor () const
 
unsigned long getBgColor () const
 
const std::string & getArgs () const
 

Private Attributes

std::string type
 
std::string pluginLocation
 
std::string fontName
 
int fontSize
 
int borderSize
 
unsigned long borderColor
 
int position
 
int size
 
unsigned long fgColor
 
unsigned long bgColor
 
std::string args
 

Constructor & Destructor Documentation

◆ ConfigDataWidget()

ConfigDataWidget::ConfigDataWidget ( )
31  :
32  type(""),
33  pluginLocation(""),
34  fontName(""),
35  fontSize(0),
36  borderSize(0),
37  borderColor(0),
38  position(0),
39  size(0),
40  fgColor(0),
41  bgColor(0),
42  args("") {}
std::string args
Definition: ConfigDataWidget.hpp:62
std::string fontName
Definition: ConfigDataWidget.hpp:54
std::string type
Definition: ConfigDataWidget.hpp:52
std::string pluginLocation
Definition: ConfigDataWidget.hpp:53
int position
Definition: ConfigDataWidget.hpp:58
unsigned long bgColor
Definition: ConfigDataWidget.hpp:61
unsigned long fgColor
Definition: ConfigDataWidget.hpp:60
int fontSize
Definition: ConfigDataWidget.hpp:55
int borderSize
Definition: ConfigDataWidget.hpp:56
unsigned long borderColor
Definition: ConfigDataWidget.hpp:57
int size
Definition: ConfigDataWidget.hpp:59

◆ ~ConfigDataWidget()

ConfigDataWidget::~ConfigDataWidget ( )
overridedefault

Member Function Documentation

◆ configInit()

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

Initialize the configuration.

Parameters
root_

Implements ConfigDataBase.

44  {
45  if (root.empty() || !root.isObject()) {
46  throw std::runtime_error("Invalid configuration file");
47  }
48  if (root["Type"].empty() || !root["Type"].isString()) {
49  Logger::GetInstance()->Log("ConfigDataWidget::Type is empty or not a string",L_ERROR);
50  } else {
51  type = root["Type"].asString();
52  }
53  if (root["Plugin"].empty() || !root["Plugin"].isString()) {
54  Logger::GetInstance()->Log("ConfigDataWidget::Plugin_Location is empty or not a string", L_ERROR);
55  } else {
56  pluginLocation = root["Plugin"].asString();
57  }
58  if (root["Font"].empty() || !root["Font"].isString()) {
59  Logger::GetInstance()->Log("ConfigDataWidget::Font_Name is empty or not a string",L_ERROR);
60  } else {
61  fontName = root["Font"].asString();
62  }
63  if (root["Font_Size"].empty() || !root["Font_Size"].isInt()) {
64  Logger::GetInstance()->Log("ConfigDataWidget::Font_Size is empty or not an integer",L_ERROR);
65  } else {
66  fontSize = root["Font_Size"].asInt();
67  }
68  if (root["Border_Size"].empty() || !root["Border_Size"].isInt()) {
69  Logger::GetInstance()->Log("ConfigDataWidget::Border_Size is empty or not an integer",L_ERROR);
70  } else {
71  borderSize = root["Border_Size"].asInt();
72  }
73  if (root["Border_Color"].empty() || !root["Border_Color"].isString()) {
74  Logger::GetInstance()->Log("ConfigDataWidget::Border_Color is empty or not a string",L_ERROR);
75  } else {
76  borderColor = ConfigHandler::colorCodeToULong(root["Border_Color"].asString());
77  }
78  if (root["Position"].empty() || !root["Position"].isInt()) {
79  Logger::GetInstance()->Log("ConfigDataWidget::Position is empty or not an integer",L_ERROR);
80  } else {
81  position = root["Position"].asInt();
82  }
83  if (root["Size"].empty() || !root["Size"].isInt()) {
84  Logger::GetInstance()->Log("ConfigDataWidget::Size is empty or not an integer",L_ERROR);
85  } else {
86  size = root["Size"].asInt();
87  }
88  if (root["Color"].empty() || !root["Color"].isString()) {
89  Logger::GetInstance()->Log("ConfigDataWidget::Foreground_Color is empty or not a string",L_ERROR);
90  } else {
91  fgColor = ConfigHandler::colorCodeToULong(root["Color"].asString());
92  }
93  if (root["Background_Color"].empty() || !root["Background_Color"].isString()) {
94  Logger::GetInstance()->Log("ConfigDataWidget::Background_Color is empty or not a string",L_ERROR);
95  } else {
96  bgColor = ConfigHandler::colorCodeToULong(root["Background_Color"].asString());
97  }
98  if (!root["Arguments"].isString()) {
99  Logger::GetInstance()->Log("ConfigDataWidget::Args is empty or not a string",L_ERROR);
100  } else {
101  args = root["Arguments"].asString();
102  }
103 }
@ L_ERROR
Definition: Logger.hpp:51
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 args, bgColor, borderColor, borderSize, ConfigHandler::colorCodeToULong(), fgColor, fontName, fontSize, Logger::GetInstance(), L_ERROR, Logger::Log(), pluginLocation, position, size, and type.

Here is the call graph for this function:

◆ configSave()

Json::Value ConfigDataWidget::configSave ( )
overridevirtual

Build a Json::Value object with the configuration.

Returns
Json::Value Object with the current runtime configuration

Implements ConfigDataBase.

105  {
106  return Json::Value();
107 }

◆ getArgs()

const std::string & ConfigDataWidget::getArgs ( ) const
119 { return args; }

References args.

◆ getBgColor()

unsigned long ConfigDataWidget::getBgColor ( ) const
118 { return bgColor; }

References bgColor.

◆ getBorderColor()

unsigned long ConfigDataWidget::getBorderColor ( ) const
114 { return borderColor; }

References borderColor.

◆ getBorderSize()

int ConfigDataWidget::getBorderSize ( ) const
113 { return borderSize; }

References borderSize.

◆ getFgColor()

unsigned long ConfigDataWidget::getFgColor ( ) const
117 { return fgColor; }

References fgColor.

◆ getFontName()

const std::string & ConfigDataWidget::getFontName ( ) const
111 { return fontName; }

References fontName.

◆ getFontSize()

int ConfigDataWidget::getFontSize ( ) const
112 { return fontSize; }

References fontSize.

◆ getPluginLocation()

const std::string & ConfigDataWidget::getPluginLocation ( ) const
110 { return pluginLocation; }

References pluginLocation.

◆ getPosition()

int ConfigDataWidget::getPosition ( ) const
115 { return position; }

References position.

◆ getSize()

int ConfigDataWidget::getSize ( ) const
116 { return size; }

References size.

◆ getType()

const std::string & ConfigDataWidget::getType ( ) const
109 { return type; }

References type.

Member Data Documentation

◆ args

std::string ConfigDataWidget::args
private

Referenced by configInit(), and getArgs().

◆ bgColor

unsigned long ConfigDataWidget::bgColor
private

Referenced by configInit(), and getBgColor().

◆ borderColor

unsigned long ConfigDataWidget::borderColor
private

Referenced by configInit(), and getBorderColor().

◆ borderSize

int ConfigDataWidget::borderSize
private

Referenced by configInit(), and getBorderSize().

◆ fgColor

unsigned long ConfigDataWidget::fgColor
private

Referenced by configInit(), and getFgColor().

◆ fontName

std::string ConfigDataWidget::fontName
private

Referenced by configInit(), and getFontName().

◆ fontSize

int ConfigDataWidget::fontSize
private

Referenced by configInit(), and getFontSize().

◆ pluginLocation

std::string ConfigDataWidget::pluginLocation
private

Referenced by configInit(), and getPluginLocation().

◆ position

int ConfigDataWidget::position
private

Referenced by configInit(), and getPosition().

◆ size

int ConfigDataWidget::size
private

Referenced by configInit(), and getSize().

◆ type

std::string ConfigDataWidget::type
private

Referenced by configInit(), and getType().


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