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
8de75a8c
Commit
8de75a8c
authored
Jun 02, 2015
by
Axel Auweter
Browse files
Cleanups.
parent
6ff0040e
Changes
5
Hide whitespace changes
Inline
Side-by-side
DCDBLib/include/c_api.h
View file @
8de75a8c
...
...
@@ -25,6 +25,7 @@ typedef enum {
DCDB_C_OK
,
DCDB_C_CONNERR
,
DCDB_C_SENSORNOTFOUND
,
DCDB_C_EMPTYSET
,
DCDB_C_UNKNOWN
}
DCDB_C_RESULT
;
...
...
DCDBLib/include/sensordatastore.h
View file @
8de75a8c
...
...
@@ -24,6 +24,11 @@
#ifndef SENSORDATASTORE_H_
#define SENSORDATASTORE_H_
typedef
enum
{
SDS_OK
,
SDS_EMPTYSET
}
SDSQueryResult
;
/* Forward-declaration of the implementation-internal classes */
class
SensorDataStoreImpl
;
...
...
@@ -89,8 +94,9 @@ public:
* @param sid The SensorId to query.
* @param start Start of the time series.
* @param end End of the time series.
* @return SDS_OK if ok, SDS_EMPTYSET if not at least 2 readings in interval.
*/
void
querySum
(
int64_t
&
result
,
SensorId
sid
,
DCDBTimeStamp
start
,
DCDBTimeStamp
end
);
SDSQueryResult
querySum
(
int64_t
&
result
,
SensorId
sid
,
DCDBTimeStamp
start
,
DCDBTimeStamp
end
);
/**
* @brief A shortcut constructor for a SensorDataStore object
...
...
DCDBLib/include_internal/sensordatastore_internal.h
View file @
8de75a8c
...
...
@@ -70,8 +70,9 @@ public:
* @param sid The SensorId to query.
* @param start Start of the time series.
* @param end End of the time series.
* @return SDS_OK if ok, SDS_EMPTYSET if not at least 2 readings in interval.
*/
void
querySum
(
int64_t
&
result
,
SensorId
sid
,
DCDBTimeStamp
start
,
DCDBTimeStamp
end
);
SDSQueryResult
querySum
(
int64_t
&
result
,
SensorId
sid
,
DCDBTimeStamp
start
,
DCDBTimeStamp
end
);
/**
* @brief This is the standard constructor of the SensorDataStoreImpl class.
...
...
DCDBLib/src/c_api.cpp
View file @
8de75a8c
...
...
@@ -81,7 +81,11 @@ DCDB_C_RESULT dcdbQuerySum(
/* Iterate over the expanded list of sensorIds and sum up the results */
for
(
std
::
list
<
SensorId
>::
iterator
sit
=
sensorIds
.
begin
();
sit
!=
sensorIds
.
end
();
sit
++
)
{
int64_t
tmp_result
=
0
;
sensorDataStore
.
querySum
(
tmp_result
,
*
sit
,
start
,
end
);
if
(
sensorDataStore
.
querySum
(
tmp_result
,
*
sit
,
start
,
end
)
==
SDS_EMPTYSET
)
{
/* In case there is no reading for this sensor, invalidate everything */
*
result
=
0
;
return
DCDB_C_EMPTYSET
;
}
*
result
+=
tmp_result
;
}
...
...
DCDBLib/src/sensordatastore.cpp
View file @
8de75a8c
...
...
@@ -233,13 +233,17 @@ void SensorDataStoreImpl::query(std::list<SensorDataStoreReading>& result, Senso
* by first querying for the result set list using query() and then
* summing up the result.
*/
void
SensorDataStoreImpl
::
querySum
(
int64_t
&
result
,
SensorId
sid
,
DCDBTimeStamp
start
,
DCDBTimeStamp
end
)
SDSQueryResult
SensorDataStoreImpl
::
querySum
(
int64_t
&
result
,
SensorId
sid
,
DCDBTimeStamp
start
,
DCDBTimeStamp
end
)
{
std
::
list
<
SensorDataStoreReading
>
queryResult
;
/* Issue a standard query */
query
(
queryResult
,
sid
,
start
,
end
);
/* Check if at least 2 readings in result */
if
(
queryResult
.
size
()
<
2
)
return
SDS_EMPTYSET
;
/* Integrate the result */
result
=
0
;
...
...
@@ -268,6 +272,7 @@ void SensorDataStoreImpl::querySum(int64_t& result, SensorId sid, DCDBTimeStamp
}
prev
=
*
it
;
}
return
SDS_OK
;
}
/**
...
...
@@ -337,9 +342,9 @@ void SensorDataStore::query(std::list<SensorDataStoreReading>& result, SensorId
* forwards to the insert function of the SensorDataStoreImpl
* class.
*/
void
SensorDataStore
::
querySum
(
int64_t
&
result
,
SensorId
sid
,
DCDBTimeStamp
start
,
DCDBTimeStamp
end
)
SDSQueryResult
SensorDataStore
::
querySum
(
int64_t
&
result
,
SensorId
sid
,
DCDBTimeStamp
start
,
DCDBTimeStamp
end
)
{
impl
->
querySum
(
result
,
sid
,
start
,
end
);
return
impl
->
querySum
(
result
,
sid
,
start
,
end
);
}
/**
...
...
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