Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
dcdb
dcdb
Commits
bbf9499c
Commit
bbf9499c
authored
Jan 10, 2019
by
Micha Mueller
Browse files
Add copy constr and assignment op to PDU, Perf, SNMP, SysFS plugins
parent
b91493e7
Changes
12
Hide whitespace changes
Inline
Side-by-side
src/sensors/pdu/PDUSensorBase.h
View file @
bbf9499c
...
...
@@ -17,8 +17,19 @@ public:
PDUSensorBase
(
const
std
::
string
&
name
)
:
SensorBase
(
name
)
{}
PDUSensorBase
(
const
PDUSensorBase
&
other
)
:
SensorBase
(
other
),
_xmlPath
(
other
.
_xmlPath
)
{}
virtual
~
PDUSensorBase
()
{}
PDUSensorBase
&
operator
=
(
const
PDUSensorBase
&
other
)
{
SensorBase
::
operator
=
(
other
);
_xmlPath
=
other
.
_xmlPath
;
return
*
this
;
}
const
xmlPathVector_t
&
getXMLPath
()
const
{
return
_xmlPath
;
}
void
setXMLPath
(
const
std
::
string
&
path
)
{
std
::
vector
<
std
::
string
>
subStrings
;
...
...
src/sensors/pdu/PDUSensorGroup.cpp
View file @
bbf9499c
...
...
@@ -17,8 +17,21 @@ PDUSensorGroup::PDUSensorGroup(const std::string& name) :
_pdu
=
nullptr
;
}
PDUSensorGroup
::
PDUSensorGroup
(
const
PDUSensorGroup
&
other
)
:
SensorGroupTemplate
(
other
),
_request
(
other
.
_request
),
_pdu
(
other
.
_pdu
)
{}
PDUSensorGroup
::~
PDUSensorGroup
()
{}
PDUSensorGroup
&
PDUSensorGroup
::
operator
=
(
const
PDUSensorGroup
&
other
)
{
SensorGroupTemplate
::
operator
=
(
other
);
_request
=
other
.
_request
;
_pdu
=
other
.
_pdu
;
return
*
this
;
}
void
PDUSensorGroup
::
init
(
boost
::
asio
::
io_service
&
io
)
{
SensorGroupTemplate
::
init
(
io
);
if
(
_pdu
)
{
...
...
src/sensors/pdu/PDUSensorGroup.h
View file @
bbf9499c
...
...
@@ -15,7 +15,9 @@ class PDUSensorGroup: public SensorGroupTemplate<PDUSensorBase> {
public:
PDUSensorGroup
(
const
std
::
string
&
name
);
PDUSensorGroup
(
const
PDUSensorGroup
&
other
);
virtual
~
PDUSensorGroup
();
PDUSensorGroup
&
operator
=
(
const
PDUSensorGroup
&
other
);
void
init
(
boost
::
asio
::
io_service
&
io
)
override
;
void
start
()
override
;
...
...
src/sensors/perfevent/PerfSensorBase.h
View file @
bbf9499c
...
...
@@ -24,8 +24,23 @@ public:
_delta
=
true
;
}
PerfSensorBase
(
const
PerfSensorBase
&
other
)
:
SensorBase
(
other
),
_type
(
other
.
_type
),
_config
(
other
.
_config
),
_lastRawPerf
(
other
.
_lastRawPerf
)
{}
virtual
~
PerfSensorBase
()
{}
PerfSensorBase
&
operator
=
(
const
PerfSensorBase
&
other
)
{
SensorBase
::
operator
=
(
other
);
_type
=
other
.
_type
;
_config
=
other
.
_config
;
_lastRawPerf
=
other
.
_lastRawPerf
;
return
*
this
;
}
unsigned
getType
()
const
{
return
_type
;
}
unsigned
getConfig
()
const
{
return
_config
;
}
...
...
src/sensors/perfevent/PerfSensorGroup.cpp
View file @
bbf9499c
...
...
@@ -31,12 +31,24 @@ PerfSensorGroup::PerfSensorGroup(const std::string& name) :
_sensorGroupLeader
(
false
),
_cpuId
(
0
),
_group_fd
(
-
1
),
_buf
(
nullptr
),
_bufSize
(
0
),
_latest_time_enabled
(
0
),
_latest_time_running
(
0
),
_lastValid
(
true
),
_maxCorrection
(
20
){
_buf
=
nullptr
;
_maxCorrection
(
20
)
{}
PerfSensorGroup
::
PerfSensorGroup
(
const
PerfSensorGroup
&
other
)
:
SensorGroupTemplate
(
other
),
_sensorGroupLeader
(
false
),
_cpuId
(
other
.
_cpuId
),
_group_fd
(
-
1
),
_buf
(
nullptr
),
_bufSize
(
0
),
_latest_time_enabled
(
0
),
_latest_time_running
(
0
),
_lastValid
(
true
),
_maxCorrection
(
other
.
_maxCorrection
)
{
}
PerfSensorGroup
::~
PerfSensorGroup
()
{
...
...
@@ -45,6 +57,21 @@ PerfSensorGroup::~PerfSensorGroup() {
}
}
PerfSensorGroup
&
PerfSensorGroup
::
operator
=
(
const
PerfSensorGroup
&
other
)
{
SensorGroupTemplate
::
operator
=
(
other
);
_sensorGroupLeader
=
false
;
_cpuId
=
other
.
_cpuId
;
_group_fd
=
-
1
;
_buf
=
nullptr
;
_bufSize
=
0
;
_latest_time_enabled
=
0
;
_latest_time_running
=
0
;
_lastValid
=
true
;
_maxCorrection
=
other
.
_maxCorrection
;
return
*
this
;
}
void
PerfSensorGroup
::
init
(
boost
::
asio
::
io_service
&
io
)
{
SensorGroupTemplate
::
init
(
io
);
...
...
src/sensors/perfevent/PerfSensorGroup.h
View file @
bbf9499c
...
...
@@ -18,7 +18,9 @@ using PerfSGPtr = std::shared_ptr<PerfSensorGroup>;
class
PerfSensorGroup
:
public
SensorGroupTemplate
<
PerfSensorBase
>
{
public:
PerfSensorGroup
(
const
std
::
string
&
name
);
PerfSensorGroup
(
const
PerfSensorGroup
&
other
);
virtual
~
PerfSensorGroup
();
PerfSensorGroup
&
operator
=
(
const
PerfSensorGroup
&
other
);
void
init
(
boost
::
asio
::
io_service
&
io
)
override
;
void
start
()
override
;
...
...
src/sensors/snmp/SNMPSensorBase.h
View file @
bbf9499c
...
...
@@ -22,8 +22,24 @@ public:
memset
(
_oid
,
0x0
,
sizeof
(
oid
)
*
MAX_OID_LEN
);
}
SNMPSensorBase
(
const
SNMPSensorBase
&
other
)
:
SensorBase
(
other
),
_oidLen
(
other
.
_oidLen
)
{
memset
(
_oid
,
0x0
,
sizeof
(
oid
)
*
MAX_OID_LEN
);
memcpy
(
_oid
,
other
.
_oid
,
other
.
_oidLen
);
}
virtual
~
SNMPSensorBase
()
{}
SNMPSensorBase
operator
=
(
const
SNMPSensorBase
&
other
)
{
SensorBase
::
operator
=
(
other
);
memset
(
_oid
,
0x0
,
sizeof
(
oid
)
*
MAX_OID_LEN
);
memcpy
(
_oid
,
other
.
_oid
,
_oidLen
);
_oidLen
=
other
.
_oidLen
;
return
*
this
;
}
void
setOID
(
const
std
::
string
&
oid
)
{
size_t
newoidnamelen
=
MAX_OID_LEN
;
if
(
read_objid
(
oid
.
c_str
(),
_oid
,
&
newoidnamelen
))
{
...
...
src/sensors/snmp/SNMPSensorGroup.cpp
View file @
bbf9499c
...
...
@@ -12,8 +12,19 @@ SNMPSensorGroup::SNMPSensorGroup(const std::string& name) :
_connection
=
nullptr
;
}
SNMPSensorGroup
::
SNMPSensorGroup
(
const
SNMPSensorGroup
&
other
)
:
SensorGroupTemplate
(
other
),
_connection
(
other
.
_connection
)
{
}
SNMPSensorGroup
::~
SNMPSensorGroup
()
{}
SNMPSensorGroup
&
SNMPSensorGroup
::
operator
=
(
const
SNMPSensorGroup
&
other
)
{
SensorGroupTemplate
::
operator
=
(
other
);
_connection
=
other
.
_connection
;
return
*
this
;
}
void
SNMPSensorGroup
::
init
(
boost
::
asio
::
io_service
&
io
)
{
SensorGroupTemplate
::
init
(
io
);
if
(
_connection
)
{
...
...
src/sensors/snmp/SNMPSensorGroup.h
View file @
bbf9499c
...
...
@@ -15,7 +15,9 @@ class SNMPSensorGroup : public SensorGroupTemplate<SNMPSensorBase> {
public:
SNMPSensorGroup
(
const
std
::
string
&
name
);
SNMPSensorGroup
(
const
SNMPSensorGroup
&
other
);
virtual
~
SNMPSensorGroup
();
SNMPSensorGroup
&
operator
=
(
const
SNMPSensorGroup
&
other
);
void
init
(
boost
::
asio
::
io_service
&
io
)
override
;
void
start
()
override
;
...
...
src/sensors/sysfs/SysfsSensorBase.h
View file @
bbf9499c
...
...
@@ -21,8 +21,24 @@ public:
//_regx = "";
}
SysfsSensorBase
(
const
SysfsSensorBase
&
other
)
:
SensorBase
(
other
),
_filter
(
other
.
_filter
),
_regx
(
other
.
_regx
),
_substitution
(
other
.
_substitution
)
{
}
virtual
~
SysfsSensorBase
()
{}
SysfsSensorBase
&
operator
=
(
const
SysfsSensorBase
&
other
)
{
SensorBase
::
operator
=
(
other
);
_filter
=
other
.
_filter
;
_regx
=
other
.
_regx
;
_substitution
=
other
.
_substitution
;
return
*
this
;
}
bool
hasFilter
()
const
{
return
_filter
;
}
boost
::
regex
getRegex
()
const
{
return
_regx
;
}
const
std
::
string
&
getSubstitution
()
const
{
return
_substitution
;
}
...
...
src/sensors/sysfs/SysfsSensorGroup.cpp
View file @
bbf9499c
...
...
@@ -17,8 +17,22 @@ SysfsSensorGroup::SysfsSensorGroup(const std::string& name) :
_file
=
NULL
;
}
SysfsSensorGroup
::
SysfsSensorGroup
(
const
SysfsSensorGroup
&
other
)
:
SensorGroupTemplate
(
other
),
_path
(
other
.
_path
)
{
_file
=
NULL
;
}
SysfsSensorGroup
::~
SysfsSensorGroup
()
{}
SysfsSensorGroup
&
SysfsSensorGroup
::
operator
=
(
const
SysfsSensorGroup
&
other
)
{
SensorGroupTemplate
::
operator
=
(
other
);
_path
=
other
.
_path
;
_file
=
NULL
;
return
*
this
;
}
void
SysfsSensorGroup
::
start
()
{
if
(
_keepRunning
)
{
//we have been started already
...
...
src/sensors/sysfs/SysfsSensorGroup.h
View file @
bbf9499c
...
...
@@ -15,7 +15,9 @@ class SysfsSensorGroup : public SensorGroupTemplate<SysfsSensorBase> {
public:
SysfsSensorGroup
(
const
std
::
string
&
name
);
SysfsSensorGroup
(
const
SysfsSensorGroup
&
other
);
virtual
~
SysfsSensorGroup
();
SysfsSensorGroup
&
operator
=
(
const
SysfsSensorGroup
&
other
);
void
start
()
override
;
void
stop
()
override
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment