From d53547934cf98e151458060ae1ec2fd3995af269 Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Fri, 18 Jun 2021 14:28:31 -0400 Subject: [PATCH] fix whitespaces --- include/villas/api/request.hpp | 39 +++++++++++++++++----------------- include/villas/format.hpp | 30 +++++++++++++++++--------- include/villas/hook.hpp | 36 +++++++++++++++++++------------ lib/api/request.cpp | 3 +-- lib/nodes/signal_generator.cpp | 1 - 5 files changed, 62 insertions(+), 47 deletions(-) diff --git a/include/villas/api/request.hpp b/include/villas/api/request.hpp index 26d16c836..35d7a3649 100644 --- a/include/villas/api/request.hpp +++ b/include/villas/api/request.hpp @@ -66,37 +66,35 @@ public: Request(Session *s) : session(s), - logger(logging.get("api:request")), method(Session::Method::UNKNOWN), contentLength(0), body(nullptr), factory(nullptr) { } - virtual ~Request() + virtual + ~Request() { if (body) json_decref(body); } - virtual void - prepare() + virtual + void prepare() { } - virtual Response * - execute() = 0; + virtual + Response * execute() = 0; - virtual void - decode(); + virtual + void decode(); - const std::string & - getMatch(int idx) const + const std::string & getMatch(int idx) const { return matches[idx]; } - std::string - getQueryArg(const std::string &arg) + std::string getQueryArg(const std::string &arg) { char buf[1024]; const char *val; @@ -106,8 +104,7 @@ public: return val ? std::string(val) : std::string(); } - std::string - getHeader(enum lws_token_indexes hdr) + std::string getHeader(enum lws_token_indexes hdr) { char buf[1024]; @@ -116,6 +113,8 @@ public: return std::string(buf); } + virtual + std::string toString(); void setLogger(Logger log) { logger = log; } @@ -126,14 +125,14 @@ class RequestFactory : public plugin::Plugin { public: using plugin::Plugin::Plugin; - virtual bool - match(const std::string &uri, std::smatch &m) const = 0; + virtual + bool match(const std::string &uri, std::smatch &m) const = 0; - virtual Request * - make(Session *s) = 0; + virtual + Request * make(Session *s) = 0; - static Request * - create(Session *s, const std::string &uri, Session::Method meth, unsigned long ct); + static + Request * create(Session *s, const std::string &uri, Session::Method meth, unsigned long ct); virtual std::string diff --git a/include/villas/format.hpp b/include/villas/format.hpp index 45c871459..3faad9fa7 100644 --- a/include/villas/format.hpp +++ b/include/villas/format.hpp @@ -35,9 +35,7 @@ class Format { protected: int flags; /**< A set of flags which is automatically used. */ - int real_precision; /**< Number of digits used for floatint point numbers */ - bool destroy_signals; Logger logger; @@ -52,7 +50,11 @@ protected: public: Format(int fl); - virtual bool isBinaryPayload() + virtual + ~Format(); + + virtual + bool isBinaryPayload() { return false; } struct vlist * getSignals() const @@ -67,13 +69,18 @@ public: void start(struct vlist *sigs, int fl = (int) SampleFlags::HAS_ALL); void start(const std::string &dtypes, int fl = (int) SampleFlags::HAS_ALL); - virtual void start() + virtual + void start() { } - virtual void parse(json_t *json); + virtual + void parse(json_t *json); - virtual int print(FILE *f, const struct sample * const smps[], unsigned cnt); - virtual int scan(FILE *f, struct sample * const smps[], unsigned cnt); + virtual + int print(FILE *f, const struct sample * const smps[], unsigned cnt); + + virtual + int scan(FILE *f, struct sample * const smps[], unsigned cnt); /** Print \p cnt samples from \p smps into buffer \p buf of length \p len. * @@ -86,7 +93,8 @@ public: * @retval >=0 The number of samples from \p smps which have been written into \p buf. * @retval <0 Something went wrong. */ - virtual int sprint(char *buf, size_t len, size_t *wbytes, const struct sample * const smps[], unsigned cnt) = 0; + virtual + int sprint(char *buf, size_t len, size_t *wbytes, const struct sample * const smps[], unsigned cnt) = 0; /** Parse samples from the buffer \p buf with a length of \p len bytes. * @@ -99,7 +107,8 @@ public: * @retval >=0 The number of samples which have been parsed from \p buf and written into \p smps. * @retval <0 Something went wrong. */ - virtual int sscan(const char *buf, size_t len, size_t *rbytes, struct sample * const smps[], unsigned cnt) = 0; + virtual + int sscan(const char *buf, size_t len, size_t *rbytes, struct sample * const smps[], unsigned cnt) = 0; /* Wrappers for sending a (un)parsing single samples */ @@ -138,7 +147,8 @@ class FormatFactory : public plugin::Plugin { public: using plugin::Plugin::Plugin; - virtual Format * make() = 0; + virtual + Format * make() = 0; static Format * make(json_t *json); diff --git a/include/villas/hook.hpp b/include/villas/hook.hpp index 20ecf472c..c288a0b17 100644 --- a/include/villas/hook.hpp +++ b/include/villas/hook.hpp @@ -76,16 +76,21 @@ protected: public: Hook(struct vpath *p, struct vnode *n, int fl, int prio, bool en = true); - virtual ~Hook(); - virtual void parse(json_t *c); + virtual + ~Hook(); + + virtual + void parse(json_t *c); + void prepare(struct vlist *sigs); void setLogger(Logger log) { logger = log; } /** Called whenever a hook is started; before threads are created. */ - virtual void start() + virtual + void start() { assert(state == State::PREPARED); @@ -93,37 +98,43 @@ public: } /** Called whenever a hook is stopped; after threads are destoyed. */ - virtual void stop() + virtual + void stop() { assert(state == State::STARTED); state = State::STOPPED; } - virtual void check() + virtual + void check() { assert(state == State::PARSED); state = State::CHECKED; } - virtual void prepare() + virtual + void prepare() { } /** Called periodically. Period is set by global 'stats' option in the configuration file. */ - virtual void periodic() + virtual + void periodic() { assert(state == State::STARTED); } /** Called whenever a new simulation case is started. This is detected by a sequence no equal to zero. */ - virtual void restart() + virtual + void restart() { assert(state == State::STARTED); } /** Called whenever a sample is processed. */ - virtual Reason process(struct sample *smp) + virtual + Reason process(struct sample *smp) { return Reason::OK; }; @@ -138,7 +149,8 @@ public: return flags; } - virtual struct vlist * getSignals() + virtual + struct vlist * getSignals() { return &signals; } @@ -208,22 +220,18 @@ public: return h; } - /// Get plugin name virtual std::string getName() const { return name; } - /// Get plugin description virtual std::string getDescription() const { return desc; } - /// Get hook flags virtual int getFlags() const { return flags; } - /// Get hook priority virtual int getPriority() const { return prio; } diff --git a/lib/api/request.cpp b/lib/api/request.cpp index 36f3fb9d5..3db96ef4f 100644 --- a/lib/api/request.cpp +++ b/lib/api/request.cpp @@ -35,8 +35,7 @@ void Request::decode() throw BadRequest("Failed to decode request payload"); } -std::string -Request::toString() +std::string Request::toString() { return fmt::format("endpoint={}, method={}", factory->getName(), Session::methodToString(method)); } diff --git a/lib/nodes/signal_generator.cpp b/lib/nodes/signal_generator.cpp index 49a95a0fa..981aaa750 100644 --- a/lib/nodes/signal_generator.cpp +++ b/lib/nodes/signal_generator.cpp @@ -344,7 +344,6 @@ int signal_generator_read(struct vnode *n, struct sample * const smps[], unsigne steps = 1; } - double running = time_delta(&s->started, &ts); t->flags = (int) SampleFlags::HAS_TS_ORIGIN | (int) SampleFlags::HAS_DATA | (int) SampleFlags::HAS_SEQUENCE;