Skip to content

Commit 7b65bea

Browse files
committed
more clang formatting
1 parent 0c2a5bb commit 7b65bea

File tree

7 files changed

+58
-67
lines changed

7 files changed

+58
-67
lines changed

include/maxplus/algebra/mpmatrix.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@
4747
#include <unordered_set>
4848
#include <vector>
4949

50-
5150
namespace MaxPlus {
5251

5352
class MPString;
@@ -192,10 +191,10 @@ class Matrix {
192191

193192
[[nodiscard]] Matrix getSubMatrixNonSquare(const std::list<unsigned int> &indices) const;
194193

195-
[[nodiscard]] Matrix getSubMatrixNonSquareRows(const std::list<unsigned int>& rowIndices) const;
194+
[[nodiscard]] Matrix getSubMatrixNonSquareRows(const std::list<unsigned int> &rowIndices) const;
196195

197196
[[nodiscard]] virtual std::shared_ptr<Matrix>
198-
getSubMatrixNonSquareRowsPtr(const std::list<unsigned int>& rowIndices) const;
197+
getSubMatrixNonSquareRowsPtr(const std::list<unsigned int> &rowIndices) const;
199198

200199
/**
201200
* Increases the number of rows of the matrix by n and fills the new elements with -\infty.

include/maxplus/base/exception/exception.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@
4444
#include "../string/cstring.h"
4545
#include <exception>
4646

47-
4847
namespace MaxPlus {
4948

5049
/*

include/maxplus/base/fsm/fsm.h

Lines changed: 33 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@
4141
#ifndef MAXPLUS_BASE_FSM_FSM_H
4242
#define MAXPLUS_BASE_FSM_FSM_H
4343

44-
#include "maxplus/base/exception/exception.h"
4544
#include "maxplus/base/basic_types.h"
45+
#include "maxplus/base/exception/exception.h"
4646
#include "maxplus/base/string/cstring.h"
4747
#include <list>
4848
#include <map>
@@ -71,7 +71,7 @@ class WithUniqueID {
7171

7272
// forward declaration of FSM state class
7373
class State;
74-
using StateRef = const State*;
74+
using StateRef = const State *;
7575

7676
// Edge of an FSM
7777
class Edge : public WithUniqueID {
@@ -112,7 +112,7 @@ class SetOfEdges : public std::map<CId, std::shared_ptr<Edge>> {
112112
void remove(const Edge &e) { this->erase(e.getId()); }
113113
};
114114

115-
using EdgeRef = const Edge*;
115+
using EdgeRef = const Edge *;
116116

117117
struct EdgeRefCompareLessThan {
118118
bool operator()(EdgeRef lhs, EdgeRef rhs) const { return lhs->lessThan(*rhs); };
@@ -136,7 +136,7 @@ class State : public WithUniqueID {
136136

137137
State(const State &) = default;
138138
State &operator=(const State &other) = delete;
139-
State(State &&) noexcept = default;
139+
State(State &&) noexcept = default;
140140
State &operator=(State &&) = delete;
141141

142142
// add an outgoing edge to the state
@@ -152,29 +152,21 @@ class State : public WithUniqueID {
152152

153153
void insertOutgoingEdge(Edge &e) { this->outgoingEdges.insert(&e); }
154154

155-
void removeOutgoingEdge(EdgeRef e) {
156-
this->outgoingEdges.erase(e);
157-
}
155+
void removeOutgoingEdge(EdgeRef e) { this->outgoingEdges.erase(e); }
158156

159157
private:
160158
SetOfEdgeRefs outgoingEdges;
161-
162159
};
163160

164-
165161
// A set of states
166162
// the set is assumed to have unique ownership of the states
167163
class SetOfStates : public std::map<CId, std::shared_ptr<State>> {
168164
public:
169165
void remove(const State &s) { this->erase(s.getId()); }
170166
virtual ~SetOfStates() = default;
171-
void addState(const std::shared_ptr<State> &s) {
172-
this->insert(std::make_pair(s->getId(), s));
173-
}
167+
void addState(const std::shared_ptr<State> &s) { this->insert(std::make_pair(s->getId(), s)); }
174168

175-
State& withId(const CId id) {
176-
return *this->at(id);
177-
}
169+
State &withId(const CId id) { return *this->at(id); }
178170
};
179171

180172
struct StateRefCompareLessThan {
@@ -207,7 +199,6 @@ class FiniteStateMachine {
207199
[[nodiscard]] virtual StateRef getInitialState() const = 0;
208200
[[nodiscard]] virtual const SetOfStateRefs &getInitialStates() const = 0;
209201
[[nodiscard]] virtual const SetOfStateRefs &getFinalStates() const = 0;
210-
211202
};
212203

213204
//
@@ -347,16 +338,17 @@ template <typename StateLabelType, typename EdgeLabelType> class Edge : public A
347338
EdgeLabelType label;
348339
};
349340

350-
template <typename StateLabelType, typename EdgeLabelType> using EdgeRef = const Edge<StateLabelType, EdgeLabelType>*;
341+
template <typename StateLabelType, typename EdgeLabelType>
342+
using EdgeRef = const Edge<StateLabelType, EdgeLabelType> *;
351343

352344
template <typename StateLabelType, typename EdgeLabelType>
353345
class SetOfEdges : public Abstract::SetOfEdges {
354346
public:
355347
using CIter = typename Abstract::SetOfEdges::const_iterator;
356348
};
357349

358-
template <typename StateLabelType, typename EdgeLabelType> using StateRef = const State<StateLabelType,EdgeLabelType>*;
359-
350+
template <typename StateLabelType, typename EdgeLabelType>
351+
using StateRef = const State<StateLabelType, EdgeLabelType> *;
360352

361353
// template <typename StateLabelType, typename EdgeLabelType>
362354
// class SetOfEdgeRefs : public Abstract::SetOfEdgeRefs {
@@ -369,13 +361,13 @@ class SetOfStates : public Abstract::SetOfStates {
369361
private:
370362
std::map<StateLabelType, std::shared_ptr<State<StateLabelType, EdgeLabelType>>> labelIndex;
371363

372-
void addToStateIndex(StateLabelType l, std::shared_ptr<State<StateLabelType, EdgeLabelType>> s) {
364+
void addToStateIndex(StateLabelType l,
365+
std::shared_ptr<State<StateLabelType, EdgeLabelType>> s) {
373366
this->labelIndex[l] = s;
374367
}
375368

376369
public:
377-
378-
State<StateLabelType, EdgeLabelType>& withLabel(StateLabelType l) {
370+
State<StateLabelType, EdgeLabelType> &withLabel(StateLabelType l) {
379371
if (this->labelIndex.find(l) != this->labelIndex.end()) {
380372
return *this->labelIndex[l];
381373
}
@@ -386,11 +378,10 @@ class SetOfStates : public Abstract::SetOfStates {
386378
return this->labelIndex.find(l) != this->labelIndex.end();
387379
}
388380

389-
void addState(std::shared_ptr<State<StateLabelType, EdgeLabelType>>& s) {
381+
void addState(std::shared_ptr<State<StateLabelType, EdgeLabelType>> &s) {
390382
Abstract::SetOfStates::addState(std::dynamic_pointer_cast<Abstract::State>(s));
391383
this->addToStateIndex(s->getLabel(), s);
392384
}
393-
394385
};
395386

396387
template <typename StateLabelType, typename EdgeLabelType>
@@ -447,17 +438,16 @@ class FiniteStateMachine : public Abstract::FiniteStateMachine {
447438
SetOfStateRefs<StateLabelType, EdgeLabelType> initialStates;
448439
SetOfStateRefs<StateLabelType, EdgeLabelType> finalStates;
449440

450-
State<StateLabelType, EdgeLabelType>& _getStateLabeled(const StateLabelType &s) {
441+
State<StateLabelType, EdgeLabelType> &_getStateLabeled(const StateLabelType &s) {
451442
return this->states.withLabel(s);
452443
};
453444

454-
State<StateLabelType, EdgeLabelType>& _getState(const State<StateLabelType, EdgeLabelType> &s) {
455-
return dynamic_cast<State<StateLabelType, EdgeLabelType>&>(this->states.withId(s.getId()));
445+
State<StateLabelType, EdgeLabelType> &_getState(const State<StateLabelType, EdgeLabelType> &s) {
446+
return dynamic_cast<State<StateLabelType, EdgeLabelType> &>(this->states.withId(s.getId()));
456447
};
457448

458-
459449
public:
460-
FiniteStateMachine() : Abstract::FiniteStateMachine() {};
450+
FiniteStateMachine() : Abstract::FiniteStateMachine(){};
461451

462452
~FiniteStateMachine() override = default;
463453

@@ -483,10 +473,10 @@ class FiniteStateMachine : public Abstract::FiniteStateMachine {
483473
EdgeLabelType lbl,
484474
const State<StateLabelType, EdgeLabelType> &dst) {
485475
// lookup state again to drop const qualifier
486-
auto &mySrc =
487-
dynamic_cast<State<StateLabelType, EdgeLabelType> &>(this->states.withId(src.getId()));
488-
auto &myDst =
489-
dynamic_cast<State<StateLabelType, EdgeLabelType> &>(this->states.withId(dst.getId()));
476+
auto &mySrc = dynamic_cast<State<StateLabelType, EdgeLabelType> &>(
477+
this->states.withId(src.getId()));
478+
auto &myDst = dynamic_cast<State<StateLabelType, EdgeLabelType> &>(
479+
this->states.withId(dst.getId()));
490480
bool added = false;
491481
auto ep = std::make_shared<Edge<StateLabelType, EdgeLabelType>>(mySrc, lbl, myDst);
492482
auto &e = *ep;
@@ -498,7 +488,7 @@ class FiniteStateMachine : public Abstract::FiniteStateMachine {
498488
void removeEdge(const Edge<StateLabelType, EdgeLabelType> &e) {
499489
auto csrc = dynamic_cast<StateRef<StateLabelType, EdgeLabelType>>(e.getSource());
500490
// get a non-const version of the state
501-
auto& src = this->_getState(*csrc);
491+
auto &src = this->_getState(*csrc);
502492
src.removeOutgoingEdge(&e);
503493
this->edges.remove(e);
504494
}
@@ -541,7 +531,6 @@ class FiniteStateMachine : public Abstract::FiniteStateMachine {
541531
this->finalStates.insert(&s);
542532
};
543533

544-
545534
[[nodiscard]] StateRef<StateLabelType, EdgeLabelType> getInitialState() const override {
546535
if (this->initialStates.empty()) {
547536
throw MaxPlus::MPException("FSM has no initial state.");
@@ -584,7 +573,9 @@ class FiniteStateMachine : public Abstract::FiniteStateMachine {
584573
return false;
585574
};
586575

587-
[[nodiscard]] const SetOfStates<StateLabelType, EdgeLabelType> &getStates() const { return this->states; };
576+
[[nodiscard]] const SetOfStates<StateLabelType, EdgeLabelType> &getStates() const {
577+
return this->states;
578+
};
588579
Abstract::SetOfStateRefs getStateRefs() {
589580
Abstract::SetOfStateRefs result;
590581
for (auto i : this->states) {
@@ -643,7 +634,8 @@ class FiniteStateMachine : public Abstract::FiniteStateMachine {
643634

644635
for (const auto &it : outgoingEdges) {
645636
auto e = dynamic_cast<const Edge<StateLabelType, EdgeLabelType> *>(it);
646-
auto dstState = dynamic_cast<StateRef<StateLabelType, EdgeLabelType>>(e->getDestination());
637+
auto dstState = dynamic_cast<StateRef<StateLabelType, EdgeLabelType>>(
638+
e->getDestination());
647639
if (e->getLabel() == lbl && dstState->getLabel() == dst) {
648640
return e;
649641
}
@@ -957,7 +949,8 @@ namespace StateStringLabeled {
957949

958950
class State : public Labeled::State<MaxPlus::MPString, char> {
959951
public:
960-
explicit State(const MaxPlus::MPString &withLabel) : Labeled::State<MaxPlus::MPString, char>(withLabel) {}
952+
explicit State(const MaxPlus::MPString &withLabel) :
953+
Labeled::State<MaxPlus::MPString, char>(withLabel) {}
961954

962955
const Abstract::SetOfEdgeRefs &getOutgoingEdges() {
963956
return dynamic_cast<const Abstract::SetOfEdgeRefs &>(
@@ -968,7 +961,8 @@ class State : public Labeled::State<MaxPlus::MPString, char> {
968961
class FiniteStateMachine : public Labeled::FiniteStateMachine<MaxPlus::MPString, char> {
969962
public:
970963
[[nodiscard]] Labeled::StateRef<MaxPlus::MPString, char> getInitialState() const override {
971-
return dynamic_cast<Labeled::StateRef<MaxPlus::MPString, char>>(Labeled::FiniteStateMachine<MaxPlus::MPString, char>::getInitialState());
964+
return dynamic_cast<Labeled::StateRef<MaxPlus::MPString, char>>(
965+
Labeled::FiniteStateMachine<MaxPlus::MPString, char>::getInitialState());
972966
};
973967

974968
void setInitialStateLabeled(const MaxPlus::MPString &sl);

include/maxplus/base/fsm/iofsm.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ using InputAction = MaxPlus::MPString;
1111
using OutputAction = MaxPlus::MPString;
1212
using IOAEdgeLabel = std::pair<InputAction, OutputAction>;
1313
using IOAState = ::FSM::Labeled::State<CId, IOAEdgeLabel>;
14-
using IOAStateRef = const IOAState*;
14+
using IOAStateRef = const IOAState *;
1515
using IOAEdge = ::FSM::Labeled::Edge<CId, IOAEdgeLabel>;
1616
using IOAEdgeRef = ::FSM::Labeled::EdgeRef<CId, IOAEdgeLabel>;
1717
using IOASetOfStates = ::FSM::Labeled::SetOfStates<CId, MaxPlus::MPString>;

include/maxplus/game/policyiteration.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,8 @@ template <typename SL, typename EL> class PolicyIteration {
546546
* @return map where each vertex is mapped to the default value
547547
*/
548548
template <typename T>
549-
std::map<const State<SL, EL> *, T> initializeVector(const SetOfStates<SL, EL> &states, T value) {
549+
std::map<const State<SL, EL> *, T> initializeVector(const SetOfStates<SL, EL> &states,
550+
T value) {
550551
std::map<const State<SL, EL> *, T> vector;
551552

552553
for (auto &it : states) {

include/maxplus/graph/mpautomaton.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -99,11 +99,11 @@ using MPAEdgeLabel = struct MPAEdgeLabel {
9999
};
100100

101101
/**
102-
* Create a new edge label
103-
* @param stateId FSM state id
104-
* @param tokenId token number
105-
*/
106-
inline MPAEdgeLabel makeMPAEdgeLabel(MPDelay delay, const MPString& mode) {
102+
* Create a new edge label
103+
* @param stateId FSM state id
104+
* @param tokenId token number
105+
*/
106+
inline MPAEdgeLabel makeMPAEdgeLabel(MPDelay delay, const MPString &mode) {
107107
MPAEdgeLabel el;
108108
el.delay = delay;
109109
el.mode = mode;

include/maxplus/graph/smpls.h

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,6 @@
5050
#include <memory>
5151
#include <utility>
5252

53-
54-
5553
namespace MaxPlus::SMPLS {
5654

5755
using ModeMatrices = std::map<MPString, std::shared_ptr<MaxPlus::Matrix>>;
@@ -60,16 +58,16 @@ class EdgeLabeledModeFSM : public ::FSM::Labeled::FiniteStateMachine<CId, MPStri
6058
public:
6159
// put the destructor deliberately into the cc sourc to ensure the class vtable is accessible
6260
// see: <https://stackoverflow.com/questions/3065154/undefined-reference-to-vtable>
63-
~EdgeLabeledModeFSM() override;
61+
~EdgeLabeledModeFSM() override;
6462
virtual void removeDanglingStates();
6563
};
6664

6765
class SMPLS {
6866
public:
69-
// the mode automaton
67+
// the mode automaton
7068
EdgeLabeledModeFSM elsFSM;
7169

72-
// the mode matrices
70+
// the mode matrices
7371
ModeMatrices sm;
7472

7573
[[nodiscard]] std::shared_ptr<MaxPlusAutomaton> convertToMaxPlusAutomaton() const;
@@ -92,26 +90,26 @@ using Event = OutputAction;
9290
using EventList = std::list<Event>;
9391
using EventOutcome = MPString;
9492

95-
using ModeEventPair = std::pair<Mode,Event>;
93+
using ModeEventPair = std::pair<Mode, Event>;
9694
using EventOutcomePair = std::pair<Event, EventOutcome>;
9795

9896
class SMPLSwithEvents : public SMPLS {
9997
public:
100-
std::list<ModeEventPair> sigma; // relation between mode and event
98+
std::list<ModeEventPair> sigma; // relation between mode and event
10199
std::list<EventOutcomePair> gamma; // relation between event and outcome
102100

103101
std::shared_ptr<IOAutomaton> ioa;
104102

105103
SMPLSwithEvents() { this->ioa = std::make_shared<IOAutomaton>(); }
106104

107-
explicit SMPLSwithEvents(std::shared_ptr<IOAutomaton> ioa) : ioa(std::move(ioa)) { }
105+
explicit SMPLSwithEvents(std::shared_ptr<IOAutomaton> ioa) : ioa(std::move(ioa)) {}
108106

109107
/**
110108
* checks the consistency rules for SMPLS with events
111109
*/
112110
bool isConsistent();
113111

114-
void saveDeterminizedIOAtoFile(const MPString& file);
112+
void saveDeterminizedIOAtoFile(const MPString &file);
115113

116114
/**
117115
* creates a max-plus automaton from SMPLS with events
@@ -121,7 +119,7 @@ class SMPLSwithEvents : public SMPLS {
121119
/*
122120
* goes through the gamma relation and finds the event of the outcome
123121
*/
124-
[[nodiscard]] Event findEventByOutcome(const EventOutcome& outcome) const;
122+
[[nodiscard]] Event findEventByOutcome(const EventOutcome &outcome) const;
125123

126124
private:
127125
std::list<std::shared_ptr<DissectedModeMatrix>> disMatrices;
@@ -137,18 +135,18 @@ class SMPLSwithEvents : public SMPLS {
137135
/*
138136
* goes through the sigma relation and finds the event emitted by mode
139137
*/
140-
[[nodiscard]] Event findEventByMode(const Mode& mode) const;
138+
[[nodiscard]] Event findEventByMode(const Mode &mode) const;
141139

142140
/**
143141
* smpls with events needs to prepare the matrices to be able to perform analysis.
144142
* this includes adding rows and columns of -inf and 0 based on the spec
145143
* allowing the system to analyze processing or conveying event timings
146144
*/
147145
void prepareMatrices(const IOAState &s,
148-
std::multiset<Event>& eventList,
149-
IOASetOfEdgeRefs& visitedEdges);
146+
std::multiset<Event> &eventList,
147+
IOASetOfEdgeRefs &visitedEdges);
150148

151-
std::shared_ptr<DissectedModeMatrix> findDissectedModeMatrix(const MPString& sName);
149+
std::shared_ptr<DissectedModeMatrix> findDissectedModeMatrix(const MPString &sName);
152150

153151
/**
154152
* recursive part of isConsistent
@@ -157,15 +155,15 @@ class SMPLSwithEvents : public SMPLS {
157155
EventList &eventList,
158156
const IOASetOfStates &finalStates,
159157
MPString &errMsg,
160-
std::map<IOAStateRef,EventList> &visited);
158+
std::map<IOAStateRef, EventList> &visited);
161159

162160
void determinizeUtil(const IOAState &s,
163-
IOASetOfStateRefs& visited,
161+
IOASetOfStateRefs &visited,
164162
const IOASetOfStateRefs &finalStates,
165163
MPString &errMsg,
166164
std::ofstream &outfile);
167165

168-
static bool compareEventLists(EventList& l1, EventList& l2);
166+
static bool compareEventLists(EventList &l1, EventList &l2);
169167

170168
void dissectModeMatrices();
171169
};

0 commit comments

Comments
 (0)