Skip to content

Commit

Permalink
Apply clang-format with adapted settings (#399)
Browse files Browse the repository at this point in the history
  • Loading branch information
andig committed Nov 17, 2019
1 parent f27adad commit 65cab14
Show file tree
Hide file tree
Showing 101 changed files with 5,795 additions and 5,880 deletions.
6 changes: 6 additions & 0 deletions .clang-format
@@ -0,0 +1,6 @@
BasedOnStyle: LLVM
ColumnLimit: 100
IndentWidth: 4
TabWidth: 4
UseTab: ForContinuationAndIndentation
AlignTrailingComments: true
21 changes: 9 additions & 12 deletions .editorconfig
@@ -1,19 +1,16 @@
# This file is for unifying the coding style for different editors and IDEs
# editorconfig.org

# top-most EditorConfig file
root = true

# Unix-style newlines with a newline ending every file
[*]
charset = utf-8
trim_trailing_whitespace = true
end_of_line = lf
insert_final_newline = true

[**.cpp]
indent_style = tab
indent_size = 4

[**.hpp]
# Tab indentation (no size specified)
[Makefile]
indent_style = tab
indent_size = 4

[**.h]
indent_style = tab
indent_size = 4
[*.{c,h,cpp,hpp}]
indent_size = 4
135 changes: 75 additions & 60 deletions .travis.yml
@@ -1,72 +1,87 @@
sudo: required
dist: trusty
dist: xenial

language: cpp

compiler:
- clang
- gcc

env:
- CTEST_OUTPUT_ON_FAILURE=1 USE_GCC7=0
- CTEST_OUTPUT_ON_FAILURE=1 USE_GCC7=1
addons:
apt:
sources:
- llvm-toolchain-trusty
packages:
- clang-format-9

matrix:
exclude:
- compiler: clang
env: CTEST_OUTPUT_ON_FAILURE=1 USE_GCC7=1
include:
- env: BUILD=1 CTEST_OUTPUT_ON_FAILURE=1 USE_GCC7=1
compiler: clang
- env: BUILD=1 CTEST_OUTPUT_ON_FAILURE=1 USE_GCC7=1
compiler: gcc
- env: BUILD=1 CTEST_OUTPUT_ON_FAILURE=1 USE_GCC7=0
compiler: gcc
- env: FORMAT=1

before_install:
- sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y
- sudo apt-get update -qq
# uncomment for ubuntu precise. not needed for >=trusty - if [ "$CXX" = "g++" ]; then sudo apt-get install -y -qq g++-4.8; export CXX="g++-4.8" CC="gcc-4.8"; else echo "yes" | sudo add-apt-repository 'deb http://ppa.launchpad.net/ubuntu-toolchain-r/test/ubuntu precise main'; echo "yes" | sudo add-apt-repository 'deb http://llvm.org/apt/precise/ llvm-toolchain-precise-3.6 main'; wget -O - http://llvm.org/apt/llvm-snapshot.gpg.key | sudo apt-key add -; sudo apt-get update; sudo apt-get install -qq --allow-unauthenticated llvm-3.6 llvm-3.6-dev clang-3.6 libstdc++-4.8-dev; export CXX="clang++-3.6" CC="clang-3.6"; fi
- if [ "$USE_GCC7" = "1" ]; then sudo apt-get install -y -qq g++-7; export CXX="g++-7" CC="gcc-7"; fi
- $CXX --version
# install json-c
- sudo apt-get install -y build-essential
- sudo apt-get install -y wget
- sudo apt-get install -y libtool
- git clone -b json-c-0.12 https://github.com/json-c/json-c
- cd json-c
- sh autogen.sh
- ./configure
- make
- sudo make install
- cd ..
- sudo apt-get install -y libcurl4-openssl-dev openssl libmicrohttpd-dev uuid-dev uuid-runtime libunistring-dev
# -- get libsml --
- git clone https://github.com/volkszaehler/libsml.git # or github.com/TheCount/libsml.git # or https://github.com/dailab/libsml.git
- cd libsml
- # git checkout develop # only dev branch seems to work
- make
# -- install libsml --
- sudo cp sml/lib/libsml.* /usr/lib/.
- sudo cp -R sml/include/* /usr/include/.
- sudo cp sml.pc /usr/lib/pkgconfig/.
- cd ..
- clang-format --version

install:
- |
if [ -n "$BUILD" ]; then
sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y
sudo apt-get update -qq
if [ "$USE_GCC7" = "1" ]; then sudo apt-get install -y -qq g++-7; export CXX="g++-7" CC="gcc-7"; fi
$CXX --version
# install json-c
sudo apt-get install -y build-essential
sudo apt-get install -y wget
sudo apt-get install -y libtool
git clone -b json-c-0.12 https://github.com/json-c/json-c
cd json-c
sh autogen.sh
./configure
make
sudo make install
cd ..
sudo apt-get install -y libcurl4-openssl-dev openssl libmicrohttpd-dev uuid-dev uuid-runtime libunistring-dev
# -- get libsml --
git clone https://github.com/volkszaehler/libsml.git # or github.com/TheCount/libsml.git # or https://github.com/dailab/libsml.git
cd libsml
# git checkout develop # only dev branch seems to work
make
# -- install libsml --
sudo cp sml/lib/libsml.* /usr/lib/.
sudo cp -R sml/include/* /usr/include/.
sudo cp sml.pc /usr/lib/pkgconfig/.
cd ..
# -- install leptonica
sudo apt-get install -y libpng-dev libtiff-dev
wget http://www.leptonica.org/source/leptonica-1.71.tar.gz
tar -zxvf leptonica-1.71.tar.gz
cd leptonica-1.71
./configure --disable-programs
make
sudo make install
sudo ldconfig
cd ..
# -- install leptonica
- sudo apt-get install -y libpng-dev libtiff-dev
- wget http://www.leptonica.org/source/leptonica-1.71.tar.gz
- tar -zxvf leptonica-1.71.tar.gz
- cd leptonica-1.71
- ./configure --disable-programs
- make
- sudo make install
- sudo ldconfig
- cd ..
# -- install libmbus
git clone https://github.com/rscada/libmbus
cd libmbus
./build.sh
sudo make install
cd ..
sudo apt-get install -y lcov
# -- install libmbus
- git clone https://github.com/rscada/libmbus
- cd libmbus
- ./build.sh
- sudo make install
- cd ..
- sudo apt-get install -y lcov
# -- install libmosquitto-dev
sudo add-apt-repository ppa:mosquitto-dev/mosquitto-ppa -y
sudo apt-get update -qq
sudo apt-get install -qq libmosquitto-dev
fi
# -- install libmosquitto-dev
- sudo add-apt-repository ppa:mosquitto-dev/mosquitto-ppa -y
- sudo apt-get update -qq
- sudo apt-get install -qq libmosquitto-dev
script:
- cmake . -DMETEREXEC_ROOTACCESS=OFF -DENABLE_OCR=ON -DSML_HOME=/usr/local/src/libsml/sml && make && make test
- if [ -n "$BUILD" ]; then cmake . -DMETEREXEC_ROOTACCESS=OFF -DENABLE_OCR=ON -DSML_HOME=/usr/local/src/libsml/sml && make && make test; fi
- |
if [ -n "$FORMAT" ]; then
clang-format -i include/**/*.{h,hpp} src/**/*.cpp tests/**/*.{cpp,hpp}
test -z "$(git status --porcelain)" || (git status; git diff; false)
fi
36 changes: 18 additions & 18 deletions include/ApiIF.hpp
Expand Up @@ -35,30 +35,30 @@

#include <string>

#include <common.h>
#include <Channel.hpp>
#include <common.h>

namespace vz {
class ApiIF {
public:
typedef vz::shared_ptr<ApiIF> Ptr;
class ApiIF {
public:
typedef vz::shared_ptr<ApiIF> Ptr;

ApiIF(Channel::Ptr ch) : _ch(ch){}
virtual ~ApiIF(){};
ApiIF(Channel::Ptr ch) : _ch(ch) {}
virtual ~ApiIF(){};

/**
* @brief send measurement values to middleware
* to be implemented specific API.
**/
virtual void send() = 0;
virtual void register_device() = 0;
protected:
Channel::Ptr channel() { return _ch; }
/**
* @brief send measurement values to middleware
* to be implemented specific API.
**/
virtual void send() = 0;
virtual void register_device() = 0;

protected:
Channel::Ptr channel() { return _ch; }

private:
Channel::Ptr _ch; /**< pointer to channel where API belongs to */
}; //class ApiIF
private:
Channel::Ptr _ch; /**< pointer to channel where API belongs to */
}; // class ApiIF

} // namespace vz
#endif /* _ApiIF_hpp_ */
40 changes: 18 additions & 22 deletions include/Buffer.hpp
Expand Up @@ -28,15 +28,15 @@
#ifndef _BUFFER_H_
#define _BUFFER_H_

#include <list>
#include <pthread.h>
#include <sys/time.h>
#include <list>

#include <Reading.hpp>

class Buffer {

public:
public:
typedef vz::shared_ptr<Buffer> Ptr;
typedef std::list<Reading>::iterator iterator;
typedef std::list<Reading>::const_iterator const_iterator;
Expand All @@ -54,45 +54,41 @@ class Buffer {
std::string dump();

inline iterator begin() { return _sent.begin(); }
inline iterator end() { return _sent.end(); }
inline size_t size() { lock(); size_t s = _sent.size(); unlock(); return s; }
inline iterator end() { return _sent.end(); }
inline size_t size() {
lock();
size_t s = _sent.size();
unlock();
return s;
}

inline bool newValues() const { return _newValues; }
inline void clear_newValues() { _newValues = false; }

inline void lock() { pthread_mutex_lock(&_mutex); }
inline void lock() { pthread_mutex_lock(&_mutex); }
inline void unlock() { pthread_mutex_unlock(&_mutex); }
inline void wait(pthread_cond_t *condition) { pthread_cond_wait(condition, &_mutex); }

inline void have_newValues() { _newValues = true; }
inline void have_newValues() { _newValues = true; }

inline void set_aggmode(Buffer::aggmode m) {_aggmode=m;}
inline void set_aggmode(Buffer::aggmode m) { _aggmode = m; }
inline aggmode get_aggmode() const { return _aggmode; }

private:
Buffer(const Buffer &); // don't allow copy constructor
Buffer & operator=(const Buffer &); // and no assignment op.
private:
Buffer(const Buffer &); // don't allow copy constructor
Buffer &operator=(const Buffer &); // and no assignment op.

std::list<Reading> _sent;
bool _newValues;

Buffer::aggmode _aggmode;

size_t _keep; /**< number of readings to cache for local interface */
size_t _keep; /**< number of readings to cache for local interface */

pthread_mutex_t _mutex;

Reading *_last_avg; // keeps value and time from last reading from aggregate call for aggmode AVG
Reading
*_last_avg; // keeps value and time from last reading from aggregate call for aggmode AVG
};

#endif /* _BUFFER_H_ */


/*
* Local variables:
* tab-width: 2
* c-indent-level: 2
* c-basic-offset: 2
* project-name: vzlogger
* End:
*/

0 comments on commit 65cab14

Please sign in to comment.