Add format script which invokes clang-format on the C++ source code (#41)

On Windows machines, clang-format.exe must be in the PATH environment variable.
This commit is contained in:
Tyler Veness
2016-05-20 17:30:37 -07:00
committed by Peter Johnson
parent 68690643d2
commit e14e45da76
383 changed files with 13787 additions and 13198 deletions

View File

@@ -8,12 +8,12 @@
#ifndef __COMMAND_H__
#define __COMMAND_H__
#include <memory>
#include <set>
#include <string>
#include "ErrorBase.h"
#include "SmartDashboard/NamedSendable.h"
#include "tables/ITableListener.h"
#include <set>
#include <string>
#include <memory>
class CommandGroup;
class Subsystem;
@@ -22,31 +22,27 @@ class Subsystem;
* The Command class is at the very core of the entire command framework.
* Every command can be started with a call to {@link Command#Start() Start()}.
* Once a command is started it will call {@link Command#Initialize()
* Initialize()}, and then
* will repeatedly call {@link Command#Execute() Execute()} until the {@link
*Command#IsFinished() IsFinished()}
* returns true. Once it does, {@link Command#End() End()} will be called.
* Initialize()}, and then will repeatedly call
* {@link Command#Execute() Execute()} until the
* {@link Command#IsFinished() IsFinished()} returns true. Once it does,
* {@link Command#End() End()} will be called.
*
* <p>However, if at any point while it is running {@link Command#Cancel()
* Cancel()} is called, then
* the command will be stopped and {@link Command#Interrupted() Interrupted()}
* will be called.</p>
* Cancel()} is called, then the command will be stopped and
* {@link Command#Interrupted() Interrupted()} will be called.</p>
*
* <p>If a command uses a {@link Subsystem}, then it should specify that it does
* so by
* calling the {@link Command#Requires(Subsystem) Requires(...)} method
* so by calling the {@link Command#Requires(Subsystem) Requires(...)} method
* in its constructor. Note that a Command may have multiple requirements, and
* {@link Command#Requires(Subsystem) Requires(...)} should be
* called for each one.</p>
* {@link Command#Requires(Subsystem) Requires(...)} should be called for each
* one.</p>
*
* <p>If a command is running and a new command with shared requirements is
* started,
* then one of two things will happen. If the active command is interruptible,
* then {@link Command#Cancel() Cancel()} will be called and the command will be
* removed
* to make way for the new one. If the active command is not interruptible, the
* other one will not even be started, and the active one will continue
* functioning.</p>
* started, then one of two things will happen. If the active command is
* interruptible, then {@link Command#Cancel() Cancel()} will be called and the
* command will be removed to make way for the new one. If the active command
* is not interruptible, the other one will not even be started, and the active
* one will continue functioning.</p>
*
* @see CommandGroup
* @see Subsystem
@@ -57,12 +53,12 @@ class Command : public ErrorBase, public NamedSendable, public ITableListener {
public:
Command();
Command(const std::string &name);
Command(const std::string& name);
Command(double timeout);
Command(const std::string &name, double timeout);
Command(const std::string& name, double timeout);
virtual ~Command();
double TimeSinceInitialized() const;
void Requires(Subsystem *s);
void Requires(Subsystem* s);
bool IsCanceled() const;
void Start();
bool Run();
@@ -70,10 +66,10 @@ class Command : public ErrorBase, public NamedSendable, public ITableListener {
bool IsRunning() const;
bool IsInterruptible() const;
void SetInterruptible(bool interruptible);
bool DoesRequire(Subsystem *subsystem) const;
typedef std::set<Subsystem *> SubsystemSet;
bool DoesRequire(Subsystem* subsystem) const;
typedef std::set<Subsystem*> SubsystemSet;
SubsystemSet GetRequirements() const;
CommandGroup *GetGroup() const;
CommandGroup* GetGroup() const;
void SetRunWhenDisabled(bool run);
bool WillRunWhenDisabled() const;
int GetID() const;
@@ -81,8 +77,8 @@ class Command : public ErrorBase, public NamedSendable, public ITableListener {
protected:
void SetTimeout(double timeout);
bool IsTimedOut() const;
bool AssertUnlocked(const std::string &message);
void SetParent(CommandGroup *parent);
bool AssertUnlocked(const std::string& message);
void SetParent(CommandGroup* parent);
/**
* The initialize method is called the first time this Command is run after
* being started.
@@ -95,12 +91,11 @@ class Command : public ErrorBase, public NamedSendable, public ITableListener {
virtual void Execute() = 0;
/**
* Returns whether this command is finished.
* If it is, then the command will be removed
* and {@link Command#end() end()} will be called.
* If it is, then the command will be removed and {@link Command#end() end()}
* will be called.
*
* <p>It may be useful for a team to reference the {@link Command#isTimedOut()
* isTimedOut()} method
* for time-sensitive commands.</p>
* isTimedOut()} method for time-sensitive commands.</p>
* @return whether this command is finished.
* @see Command#isTimedOut() isTimedOut()
*/
@@ -112,18 +107,15 @@ class Command : public ErrorBase, public NamedSendable, public ITableListener {
*/
virtual void End() = 0;
/**
* Called when the command ends because somebody called {@link
*Command#cancel() cancel()}
* or another command shared the same requirements as this one, and booted
* it out.
* Called when the command ends because somebody called
* {@link Command#cancel() cancel()} or another command shared the same
* requirements as this one, and booted it out.
*
* <p>This is where you may want
* to wrap up loose ends, like shutting off a motor that was being used
* in the command.</p>
* <p>This is where you may want to wrap up loose ends, like shutting off a
* motor that was being used in the command.</p>
*
* <p>Generally, it is useful to simply call the {@link Command#end() end()}
* method
* within this method</p>
* method within this method</p>
*/
virtual void Interrupted() = 0;
virtual void _Initialize();
@@ -170,7 +162,7 @@ class Command : public ErrorBase, public NamedSendable, public ITableListener {
bool m_runWhenDisabled = false;
/** The {@link CommandGroup} this is in */
CommandGroup *m_parent = nullptr;
CommandGroup* m_parent = nullptr;
int m_commandID = m_commandCounter++;
static int m_commandCounter;

View File

@@ -8,25 +8,24 @@
#ifndef __COMMAND_GROUP_H__
#define __COMMAND_GROUP_H__
#include "Commands/Command.h"
#include "Commands/CommandGroupEntry.h"
#include <list>
#include <vector>
#include "Commands/Command.h"
#include "Commands/CommandGroupEntry.h"
/**
* A {@link CommandGroup} is a list of commands which are executed in sequence.
*
* <p>Commands in a {@link CommandGroup} are added using the {@link
* CommandGroup#AddSequential(Command) AddSequential(...)} method
* and are called sequentially.
* {@link CommandGroup CommandGroups} are themselves {@link Command Commands}
* and can be given to other {@link CommandGroup CommandGroups}.</p>
* CommandGroup#AddSequential(Command) AddSequential(...)} method and are
* called sequentially. {@link CommandGroup CommandGroups} are themselves
* {@link Command Commands} and can be given to other
* {@link CommandGroup CommandGroups}.</p>
*
* <p>{@link CommandGroup CommandGroups} will carry all of the requirements of
* their {@link Command subcommands}. Additional
* requirements can be specified by calling {@link
*CommandGroup#Requires(Subsystem) Requires(...)}
* normally in the constructor.</P>
* their {@link Command subcommands}. Additional requirements can be specified
* by calling {@link CommandGroup#Requires(Subsystem) Requires(...)} normally
* in the constructor.</P>
*
* <p>CommandGroups can also execute commands in parallel, simply by adding them
* using {@link CommandGroup#AddParallel(Command) AddParallel(...)}.</p>
@@ -37,13 +36,13 @@
class CommandGroup : public Command {
public:
CommandGroup() = default;
CommandGroup(const std::string &name);
CommandGroup(const std::string& name);
virtual ~CommandGroup() = default;
void AddSequential(Command *command);
void AddSequential(Command *command, double timeout);
void AddParallel(Command *command);
void AddParallel(Command *command, double timeout);
void AddSequential(Command* command);
void AddSequential(Command* command, double timeout);
void AddParallel(Command* command);
void AddParallel(Command* command, double timeout);
bool IsInterruptible() const;
int GetSize() const;
@@ -59,7 +58,7 @@ class CommandGroup : public Command {
virtual void _End();
private:
void CancelConflicts(Command *command);
void CancelConflicts(Command* command);
/** The commands in this group (stored in entries) */
std::vector<CommandGroupEntry> m_commands;

View File

@@ -19,11 +19,11 @@ class CommandGroupEntry {
} Sequence;
CommandGroupEntry() = default;
CommandGroupEntry(Command *command, Sequence state, double timeout = -1.0);
CommandGroupEntry(Command* command, Sequence state, double timeout = -1.0);
bool IsTimedOut() const;
double m_timeout = -1.0;
Command *m_command = nullptr;
Command* m_command = nullptr;
Sequence m_state = kSequence_InSequence;
};

View File

@@ -10,16 +10,17 @@
#include "Commands/Command.h"
#include "PIDController.h"
#include "PIDSource.h"
#include "PIDOutput.h"
#include "PIDSource.h"
#include <memory>
class PIDCommand : public Command, public PIDOutput, public PIDSource {
public:
PIDCommand(const std::string &name, double p, double i, double d);
PIDCommand(const std::string &name, double p, double i, double d, double period);
PIDCommand(const std::string &name, double p, double i, double d, double f,
PIDCommand(const std::string& name, double p, double i, double d);
PIDCommand(const std::string& name, double p, double i, double d,
double period);
PIDCommand(const std::string& name, double p, double i, double d, double f,
double period);
PIDCommand(double p, double i, double d);
PIDCommand(double p, double i, double d, double period);

View File

@@ -10,8 +10,8 @@
#include "Commands/Subsystem.h"
#include "PIDController.h"
#include "PIDSource.h"
#include "PIDOutput.h"
#include "PIDSource.h"
#include <memory>
@@ -21,17 +21,15 @@
* an elevator which attempts to stay at a constant height).
*
* <p>It provides some convenience methods to run an internal {@link
* PIDController}.
* It also allows access to the internal {@link PIDController} in order to give
* total control
* to the programmer.</p>
* PIDController}. It also allows access to the internal {@link PIDController}
* in order to give total control to the programmer.</p>
*
*/
class PIDSubsystem : public Subsystem, public PIDOutput, public PIDSource {
public:
PIDSubsystem(const std::string &name, double p, double i, double d);
PIDSubsystem(const std::string &name, double p, double i, double d, double f);
PIDSubsystem(const std::string &name, double p, double i, double d, double f,
PIDSubsystem(const std::string& name, double p, double i, double d);
PIDSubsystem(const std::string& name, double p, double i, double d, double f);
PIDSubsystem(const std::string& name, double p, double i, double d, double f,
double period);
PIDSubsystem(double p, double i, double d);
PIDSubsystem(double p, double i, double d, double f);

View File

@@ -8,12 +8,12 @@
#ifndef __PRINT_COMMAND_H__
#define __PRINT_COMMAND_H__
#include "Commands/Command.h"
#include <string>
#include "Commands/Command.h"
class PrintCommand : public Command {
public:
PrintCommand(const std::string &message);
PrintCommand(const std::string& message);
virtual ~PrintCommand() = default;
protected:

View File

@@ -8,31 +8,31 @@
#ifndef __SCHEDULER_H__
#define __SCHEDULER_H__
#include "Commands/Command.h"
#include "ErrorBase.h"
#include "SmartDashboard/NamedSendable.h"
#include "networktables/NetworkTable.h"
#include "SmartDashboard/SmartDashboard.h"
#include <list>
#include <map>
#include <memory>
#include <set>
#include <string>
#include <vector>
#include "Commands/Command.h"
#include "ErrorBase.h"
#include "HAL/cpp/priority_mutex.h"
#include "SmartDashboard/NamedSendable.h"
#include "SmartDashboard/SmartDashboard.h"
#include "networktables/NetworkTable.h"
class ButtonScheduler;
class Subsystem;
class Scheduler : public ErrorBase, public NamedSendable {
public:
static Scheduler *GetInstance();
static Scheduler* GetInstance();
void AddCommand(Command *command);
void AddButton(ButtonScheduler *button);
void RegisterSubsystem(Subsystem *subsystem);
void AddCommand(Command* command);
void AddButton(ButtonScheduler* button);
void RegisterSubsystem(Subsystem* subsystem);
void Run();
void Remove(Command *command);
void Remove(Command* command);
void RemoveAll();
void ResetAll();
void SetEnabled(bool enabled);
@@ -48,16 +48,16 @@ class Scheduler : public ErrorBase, public NamedSendable {
Scheduler();
virtual ~Scheduler() = default;
void ProcessCommandAddition(Command *command);
void ProcessCommandAddition(Command* command);
Command::SubsystemSet m_subsystems;
priority_mutex m_buttonsLock;
typedef std::vector<ButtonScheduler *> ButtonVector;
typedef std::vector<ButtonScheduler*> ButtonVector;
ButtonVector m_buttons;
typedef std::vector<Command *> CommandVector;
typedef std::vector<Command*> CommandVector;
priority_mutex m_additionsLock;
CommandVector m_additions;
typedef std::set<Command *> CommandSet;
typedef std::set<Command*> CommandSet;
CommandSet m_commands;
bool m_adding = false;
bool m_enabled = true;

View File

@@ -12,7 +12,7 @@
class StartCommand : public Command {
public:
StartCommand(Command *commandToStart);
StartCommand(Command* commandToStart);
virtual ~StartCommand() = default;
protected:
@@ -23,7 +23,7 @@ class StartCommand : public Command {
virtual void Interrupted();
private:
Command *m_commandToFork;
Command* m_commandToFork;
};
#endif

View File

@@ -8,10 +8,10 @@
#ifndef __SUBSYSTEM_H__
#define __SUBSYSTEM_H__
#include <memory>
#include <string>
#include "ErrorBase.h"
#include "SmartDashboard/NamedSendable.h"
#include <string>
#include <memory>
class Command;
@@ -19,21 +19,21 @@ class Subsystem : public ErrorBase, public NamedSendable {
friend class Scheduler;
public:
Subsystem(const std::string &name);
Subsystem(const std::string& name);
virtual ~Subsystem() = default;
void SetDefaultCommand(Command *command);
Command *GetDefaultCommand();
void SetCurrentCommand(Command *command);
Command *GetCurrentCommand() const;
void SetDefaultCommand(Command* command);
Command* GetDefaultCommand();
void SetCurrentCommand(Command* command);
Command* GetCurrentCommand() const;
virtual void InitDefaultCommand();
private:
void ConfirmCommand();
Command *m_currentCommand = nullptr;
Command* m_currentCommand = nullptr;
bool m_currentCommandChanged = true;
Command *m_defaultCommand = nullptr;
Command* m_defaultCommand = nullptr;
std::string m_name;
bool m_initializedDefaultCommand = false;

View File

@@ -13,7 +13,7 @@
class WaitCommand : public Command {
public:
WaitCommand(double timeout);
WaitCommand(const std::string &name, double timeout);
WaitCommand(const std::string& name, double timeout);
virtual ~WaitCommand() = default;
protected:

View File

@@ -13,7 +13,7 @@
class WaitForChildren : public Command {
public:
WaitForChildren(double timeout);
WaitForChildren(const std::string &name, double timeout);
WaitForChildren(const std::string& name, double timeout);
virtual ~WaitForChildren() = default;
protected:

View File

@@ -13,7 +13,7 @@
class WaitUntilCommand : public Command {
public:
WaitUntilCommand(double time);
WaitUntilCommand(const std::string &name, double time);
WaitUntilCommand(const std::string& name, double time);
virtual ~WaitUntilCommand() = default;
protected: