Skip to content

Commit d5c1012

Browse files
committed
Release v0.1.0 of readerlib
0 parents  commit d5c1012

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+5769
-0
lines changed

.clang-format

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
BasedOnStyle: WebKit
2+
AccessModifierOffset: 0
3+
AlignAfterOpenBracket: false
4+
AlignEscapedNewlinesLeft: false
5+
AlignOperands: true
6+
AlignTrailingComments: true
7+
AllowAllParametersOfDeclarationOnNextLine: true
8+
AllowShortBlocksOnASingleLine: false
9+
AllowShortCaseLabelsOnASingleLine: false
10+
AllowShortFunctionsOnASingleLine: None
11+
AllowShortIfStatementsOnASingleLine: false
12+
AllowShortLoopsOnASingleLine: false
13+
AlwaysBreakAfterDefinitionReturnType: false
14+
AlwaysBreakBeforeMultilineStrings: false
15+
AlwaysBreakTemplateDeclarations: false
16+
BinPackArguments: true
17+
BinPackParameters: true
18+
BreakBeforeBinaryOperators: None
19+
BreakBeforeBraces: Stroustrup
20+
BreakBeforeTernaryOperators: true
21+
BreakConstructorInitializersBeforeComma: true
22+
ColumnLimit: 80
23+
CommentPragmas: '^ IWYU pragma:'
24+
ConstructorInitializerAllOnOneLineOrOnePerLine: false
25+
ConstructorInitializerIndentWidth: 4
26+
ContinuationIndentWidth: 4
27+
Cpp11BracedListStyle: false
28+
DerivePointerAlignment: false
29+
DisableFormat: false
30+
ExperimentalAutoDetectBinPacking: false
31+
IndentCaseLabels: true
32+
IndentWidth: 4
33+
IndentWrappedFunctionNames: true
34+
KeepEmptyLinesAtTheStartOfBlocks: true
35+
Language: Cpp
36+
MaxEmptyLinesToKeep: 1
37+
NamespaceIndentation: All
38+
ObjCBlockIndentWidth: 4
39+
ObjCSpaceAfterProperty: true
40+
ObjCSpaceBeforeProtocolList: true
41+
PenaltyBreakBeforeFirstCallParameter: 50
42+
PenaltyBreakComment: 300
43+
PenaltyBreakFirstLessLess: 220
44+
PenaltyBreakString: 10000
45+
PenaltyExcessCharacter: 1000000
46+
PenaltyReturnTypeOnItsOwnLine: 10000
47+
PointerAlignment: Left
48+
SpaceAfterCStyleCast: false
49+
SpaceBeforeAssignmentOperators: true
50+
SpaceBeforeParens: ControlStatements
51+
SpaceInEmptyParentheses: false
52+
SpacesBeforeTrailingComments: 1
53+
SpacesInAngles: true
54+
SpacesInCStyleCastParentheses: false
55+
SpacesInContainerLiterals: true
56+
SpacesInParentheses: false
57+
SpacesInSquareBrackets: true
58+
Standard: Cpp11
59+
TabWidth: 4
60+
UseTab: Never

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# CMake Build Directory
2+
build/**

.travis-ci/docker_bash.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/bash
2+
3+
docker exec $1 bash -c "$2"
4+

.travis-ci/install_docker.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/bin/bash
2+
sudo apt-get install -qq -y docker

.travis-ci/load_docker_image.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
# Remove image if present
6+
docker rm -f $2 &>/dev/null || true
7+
docker pull $1
8+
docker run -d -it --name $2 --privileged $1
9+
docker exec $2 mkdir $2
10+
docker cp . $2:/$2

.travis.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
sudo: true
2+
dist: trusty
3+
4+
cache:
5+
apt: true
6+
ccache: true
7+
8+
language: cpp
9+
10+
services:
11+
- docker
12+
13+
matrix:
14+
include:
15+
- install: .travis-ci/install_docker.sh
16+
script:
17+
- .travis-ci/load_docker_image.sh 'base/archlinux' 'readerlib'
18+
- .travis-ci/docker_bash.sh 'readerlib' 'pacman -Syu --noconfirm clang cmake boost boost-libs clang-tools-extra make'
19+
- .travis-ci/docker_bash.sh 'readerlib' 'cd readerlib; mkdir build; cd build; cmake ..; make; make test'

CMakeLists.txt

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
cmake_minimum_required(VERSION 3.8)
2+
3+
enable_testing()
4+
project (readerlib VERSION 0.1.0)
5+
6+
set (LIBNAME "readerlib")
7+
set (STATIC_LIBNAME "readerlib_s")
8+
9+
# Set compiler options
10+
set (CMAKE_C_STANDARD 11)
11+
set (CMAKE_C_COMPILER "/usr/bin/clang")
12+
set (CMAKE_C_FLAGS "-fPIC -Weverything -pthread")
13+
set (CMAKE_C_FLAGS_DEBUG "-g")
14+
set (CMAKE_C_FLAGS_MINSIZEREL "-Os -DNDEBUG")
15+
set (CMAKE_C_FLAGS_RELEASE "-O4 -DNDEBUG")
16+
set (CMAKE_C_FLAGS_RELWITHDEBINFO "-O2 -g")
17+
18+
set (CMAKE_CXX_STANDARD 17)
19+
set (CMAKE_CXX_COMPILER "/usr/bin/clang++")
20+
set (CMAKE_CXX_FLAGS "-fPIC -Weverything -Wno-unused-parameter -Wno-weak-vtables -Wno-c++98-compat -Wno-padded -Wno-covered-switch-default -Wno-vla -Wno-vla-extension -pthread")
21+
set (CMAKE_CXX_FLAGS_DEBUG "-g -fsanitize=undefined -fsanitize=address -fsanitize=leak")
22+
set (CMAKE_CXX_FLAGS_MINSIZEREL "-Os -DNDEBUG")
23+
set (CMAKE_CXX_FLAGS_RELEASE "-O4 -DNDEBUG")
24+
set (CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g")
25+
26+
set (CMAKE_SHARED_LINKER_FLAGS "-v -lboost_system")
27+
28+
set(Boost_USE_STATIC_LIBS ON)
29+
set(Boost_USE_MULTITHREAD ON)
30+
find_package(Boost 1.65.0 REQUIRED COMPONENTS system filesystem regex)
31+
32+
set(CMAKE_AUTOMOC ON)
33+
set(CMAKE_INCLUDE_CURRENT_DIR ON)
34+
set(CMAKE_AUTORCC ON)
35+
36+
add_subdirectory (src)
37+
add_subdirectory (test)

LICENSE

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
Copyright (c) 2016-2017, Daniel "Dadie" Korner
2+
All rights reserved.
3+
4+
Redistribution and use in source and binary forms, with or without
5+
modification, are permitted provided that the following conditions are met:
6+
7+
1. Redistributions of source code must retain the above copyright
8+
notice, this list of conditions and the following disclaimer.
9+
2. Neither the source code nor the binary may be used for any military use.
10+
11+
THIS SOFTWARE IS PROVIDED BY Daniel "Dadie" Korner ''AS IS'' AND ANY
12+
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
13+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
14+
DISCLAIMED. IN NO EVENT SHALL Daniel "Dadie" Korner BE LIABLE FOR ANY
15+
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
16+
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
17+
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
18+
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
19+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
20+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

src/CMakeLists.txt

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
cmake_minimum_required(VERSION 3.8)
2+
3+
set (READERLIB_SOURCE
4+
rlib/common/reader.cpp
5+
rlib/common/cached_reader.cpp
6+
rlib/common/statistic_reader.cpp
7+
rlib/common/synthetic_reader.cpp
8+
rlib/common/exporter.cpp
9+
rlib/common/sample.cpp
10+
rlib/common/sensor.cpp
11+
12+
rlib/android/meta_reader.cpp
13+
rlib/android/meta.cpp
14+
15+
rlib/powerscale/psi.cpp
16+
rlib/powerscale/psi_reader.cpp
17+
18+
rlib/keysight/dlog.cpp
19+
rlib/keysight/dlog_reader.cpp
20+
rlib/keysight/dlog_exporter.cpp
21+
22+
rlib/grim/grim_data.cpp
23+
rlib/grim/grim_reader.cpp
24+
25+
rlib/csv/csv_reader.cpp
26+
rlib/csv/csv_exporter.cpp
27+
28+
rlib/svg/svg_exporter.cpp
29+
30+
rlib/xml/xml_exporter.cpp
31+
rlib/xml/xml_reader.cpp
32+
33+
rlib/remote/reader.cpp
34+
)
35+
36+
include_directories("./" ${Boost_INCLUDE_DIRS})
37+
38+
include_directories(... )
39+
40+
add_library (${LIBNAME} SHARED ${READERLIB_SOURCE})
41+
target_include_directories(${LIBNAME} PUBLIC "./")
42+
target_link_libraries(${LIBNAME} ${Boost_LIBRARIES})
43+
44+
add_library (${STATIC_LIBNAME} STATIC ${READERLIB_SOURCE})
45+
target_include_directories(${STATIC_LIBNAME} PUBLIC "./")
46+
target_link_libraries(${STATIC_LIBNAME} ${Boost_LIBRARIES})

src/rlib/android/meta.cpp

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
/**
2+
* Copyright (c) 2016-2017, Daniel "Dadie" Korner
3+
* All rights reserved.
4+
*
5+
* Redistribution and use in source and binary forms, with or without
6+
* modification, are permitted provided that the following conditions are met:
7+
*
8+
* 1. Redistributions of source code must retain the above copyright
9+
* notice, this list of conditions and the following disclaimer.
10+
* 2. Neither the source code nor the binary may be used for any military use.
11+
*
12+
* THIS SOFTWARE IS PROVIDED BY Daniel "Dadie" Korner ''AS IS'' AND ANY
13+
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
14+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
15+
* DISCLAIMED. IN NO EVENT SHALL Daniel "Dadie" Korner BE LIABLE FOR ANY
16+
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
17+
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
18+
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
19+
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
20+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
21+
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
22+
**/
23+
24+
// Ext
25+
#include <boost/lexical_cast.hpp>
26+
#include <boost/property_tree/ptree.hpp>
27+
#include <boost/property_tree/xml_parser.hpp>
28+
29+
// Own
30+
#include "rlib/android/meta.h"
31+
32+
// StdLib
33+
#include <iostream>
34+
#include <sstream>
35+
#include <string>
36+
37+
rlib::android::meta::meta(std::string filename)
38+
{
39+
this->meta_filename = filename;
40+
this->data_filename = filename.substr(0, filename.size() - 4) + "data";
41+
this->event_filename = filename.substr(0, filename.size() - 4) + "event";
42+
43+
boost::property_tree::ptree meta_xml;
44+
boost::property_tree::read_xml(this->meta_filename, meta_xml);
45+
46+
this->version =
47+
meta_xml.get< std::string >("grim.<xmlattr>.version", "0.0");
48+
this->name = meta_xml.get< std::string >("grim.meta.name");
49+
this->init = meta_xml.get< uint64_t >("grim.meta.init");
50+
51+
std::string format_text(meta_xml.get< std::string >("grim.meta.format"));
52+
std::istringstream format_stream(format_text);
53+
std::string format_element;
54+
while (format_stream.good()) {
55+
std::getline(format_stream, format_element, '|');
56+
this->format.push_back(format_element);
57+
}
58+
59+
for (auto& value : meta_xml.get_child("grim.values")) {
60+
if (value.first != "value") {
61+
continue;
62+
}
63+
auto value_name =
64+
value.second.get< std::string >("<xmlattr>.name", "N.N");
65+
auto value_type =
66+
value.second.get< std::string >("<xmlattr>.type", "N.N");
67+
auto value_unit =
68+
value.second.get< std::string >("<xmlattr>.unit", "N.N");
69+
this->type[ value_name ] = value_type;
70+
this->unit[ value_name ] = value_unit;
71+
}
72+
}

0 commit comments

Comments
 (0)