-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOSInfoModule.cpp
More file actions
83 lines (65 loc) · 2.29 KB
/
OSInfoModule.cpp
File metadata and controls
83 lines (65 loc) · 2.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* OSInfoModule.cpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: kdenisov <kdenisov@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/11/03 16:08:31 by kdenisov #+# #+# */
/* Updated: 2019/11/14 11:13:13 by kdenisov ### ########.fr */
/* */
/* ************************************************************************** */
#include <unistd.h>
#include <string>
#include <sys/sysctl.h>
#include "includes/OSInfoModule.hpp"
OSInfoModule::OSInfoModule() {
}
OSInfoModule::OSInfoModule(int pos, int gpos) : _pos(pos), _gpos(gpos){
this->_module = "OSINFO";
this->_type = "Type: ";
this->_release = "Release: ";
char type[100];
char release[100];
size_t size = 100;
sysctlbyname("kern.ostype", &type, &size, NULL, 0);
this->_type += type;
sysctlbyname("kern.osrelease", &release, &size, NULL, 0);
this->_release += release;
}
OSInfoModule::~OSInfoModule() {
}
OSInfoModule::OSInfoModule(OSInfoModule const & src) {
*this = src;
}
OSInfoModule & OSInfoModule::operator=(OSInfoModule const & rfs) {
this->_module = rfs._module;
this->_type = rfs._type;
this->_release = rfs._release;
this->_pos = rfs._pos;
this->_gpos = rfs._gpos;
return (*this);
}
void OSInfoModule::render(IMonitorDisplay *d) {
d->render(this);
}
void OSInfoModule::refresh() {
}
std::string OSInfoModule::getName() const {
return (this->_module);
}
int OSInfoModule::getPos() const {
return (this->_pos);
}
int OSInfoModule::getGPos() const {
return (this->_gpos);
}
std::string OSInfoModule::getType() const {
return (this->_type);
}
std::string OSInfoModule::getRelease() const {
return (this->_release);
}
int OSInfoModule::getSize(std::string const name) const {
return (name.length());
}