cpplint: lint things a bit

https://raw.githubusercontent.com/cpplint/cpplint/HEAD/cpplint.py

Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
This commit is contained in:
Vincent Batts 2025-02-10 17:15:32 -05:00
parent 78660fb70e
commit 01101c84a0
Signed by: vbatts
GPG key ID: E30EFAA812C6E5ED
5 changed files with 64 additions and 61 deletions

View file

@ -1,3 +1,5 @@
// Copyright 2025 Vincent Batts <vbatts@hashbangbash.com>
#include <iostream> #include <iostream>
#include "account.h" #include "account.h"

View file

@ -1,41 +1,37 @@
// Copyright 2025 Vincent Batts <vbatts@hashbangbash.com>
#ifndef ACCOUNT_H_INCLUDED_ #ifndef ACCOUNT_H_
#define ACCOUNT_H_INCLUDED_ #define ACCOUNT_H_
class Account class Account {
{
public: public:
/* ==================== LIFECYCLE */
explicit Account(double initial_balance);
~Account(); // destructor
/* ==================== LIFECYCLE ======================================= */ /* ==================== ACCESSORS */
//Account (); /* constructor */
//Account ( const Account &other ); /* copy constructor */
Account ( double initial_balance );
~Account (); /* destructor */
/* ==================== ACCESSORS ======================================= */
// current balance of the Account // current balance of the Account
double getBalance() const; double getBalance() const;
/* ==================== MUTATORS ======================================= */ /* ==================== MUTATORS */
void deposit(double amount); void deposit(double amount);
void withdraw(double amount); void withdraw(double amount);
/* ==================== OPERATORS ======================================= */ /* ==================== OPERATORS */
Account& operator = ( const Account &other ); /* assignment operator */ Account& operator = (const Account &other); // assignment operator
protected: protected:
/* ==================== DATA MEMBERS ======================================= */ /* ==================== DATA MEMBERS */
private: private:
/* ==================== DATA MEMBERS ======================================= */ /* ==================== DATA MEMBERS */
double balance; double balance;
};
}; /* ----- end of class Account ----- */ #endif // ACCOUNT_H_
#endif // ACCOUNT_H_INCLUDED_
// vim:set sts=2 sw=2 et: // vim:set sts=2 sw=2 et:

View file

@ -1,6 +1,7 @@
// Copyright 2025 Vincent Batts <vbatts@hashbangbash.com>
#ifndef COMMON_H_INCLUDED_ #ifndef COMMON_H_
#define COMMON_H_INCLUDED_ #define COMMON_H_
#include <iostream> #include <iostream>
@ -11,6 +12,6 @@
#define log_err(hurr) \ #define log_err(hurr) \
std::cerr << "[" << __FILE__ << ":" << __LINE__ << "] " << hurr << std::endl; std::cerr << "[" << __FILE__ << ":" << __LINE__ << "] " << hurr << std::endl;
#endif // COMMON_H_INCLUDED_ #endif // COMMON_H_
// vim:set sts=2 sw=2 et: // vim:set sts=2 sw=2 et:

View file

@ -1,3 +1,4 @@
// Copyright 2025 Vincent Batts <vbatts@hashbangbash.com>
/* /*
* ===================================================================================== * =====================================================================================
* *
@ -19,9 +20,9 @@
#include <cmath> #include <cmath>
#include <cstdlib> #include <cstdlib>
#include "common.h" #include "./common.h"
#include "account.h" #include "./account.h"
#include "worker.h" #include "./worker.h"
Account* do_account() { Account* do_account() {
Account* account = new Account(0.0); Account* account = new Account(0.0);
@ -39,7 +40,6 @@ void scoped_account() {
account->withdraw(100); account->withdraw(100);
log_out("Current Balance: " << account->getBalance()); log_out("Current Balance: " << account->getBalance());
log_err("dang"); log_err("dang");
delete account;
} }

View file

@ -1,9 +1,11 @@
// Copyright 2025 Vincent Batts <vbatts@hashbangbash.com>
// https://en.cppreference.com/w/cpp/thread/thread // https://en.cppreference.com/w/cpp/thread/thread
// https://en.cppreference.com/w/cpp/thread/mutex // https://en.cppreference.com/w/cpp/thread/mutex
// https://en.cppreference.com/w/cpp/thread/condition_variable // https://en.cppreference.com/w/cpp/thread/condition_variable
#ifndef WORKER_H_INCLUDED_ #ifndef WORKER_H_
#define WORKER_H_INCLUDED_ #define WORKER_H_
#include <iostream> #include <iostream>
#include <thread> #include <thread>
@ -11,18 +13,19 @@
#include <mutex> #include <mutex>
namespace Dang { namespace Dang {
class Worker { class Worker {
public: public:
Worker() { Worker() {
this->ready = false; this->ready = false;
//init(); }
};
void run() { void run() {
std::unique_lock<std::mutex> lock(this->mtx); std::unique_lock<std::mutex> lock(this->mtx);
this->cv.wait(lock, [this] { return this->ready; }); // Wait until 'ready' is set to true // Wait until 'ready' is set to true
this->cv.wait(lock, [this] { return this->ready; });
std::cout << "Daemon process woke up!" << std::endl; std::cout << "Daemon process woke up!" << std::endl;
}; }
int work() { int work() {
std::thread daemon([this] {this->run();}); std::thread daemon([this] {this->run();});
@ -36,15 +39,16 @@ namespace Dang {
daemon.join(); daemon.join();
return 0; return 0;
}; }
private: private:
std::mutex mtx; std::mutex mtx;
std::condition_variable cv; std::condition_variable cv;
bool ready; bool ready;
}; };
}
#endif // WORKER_H_INCLUDED_ } // namespace Dang
#endif // WORKER_H_
// vim:set sts=2 sw=2 et: // vim:set sts=2 sw=2 et: