Skip to content

avoid name collisions with Queue and Table #22

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 7, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
### Added

### Changed
- Queue and Table are now ArduinoCIQueue and ArduinoCITable to avoid name collisions

### Deprecated

Expand Down
2 changes: 2 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ Be prepared to write tests to accompany any code you would like to see merged.
* `git add README.md CHANGELOG.md lib/arduino_ci/version.rb`
* `git commit -m "vVERSION bump"`
* `git tag -a vVERSION -m "Released version VERSION"`
* `git stash save`
* `gem build arduino_ci.gemspec`
* `git stash pop`
* `gem push arduino_ci-VERSION.gem`
* `git push upstream`
* `git push upstream --tags`
6 changes: 3 additions & 3 deletions SampleProjects/TestSomething/test/queue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

unittest(basic_queue_dequeue_and_size)
{
Queue<int> q;
ArduinoCIQueue<int> q;
int data[5] = {11, 22, 33, 44, 55};

assertTrue(q.empty());
Expand All @@ -27,11 +27,11 @@ unittest(basic_queue_dequeue_and_size)

unittest(copy_constructor)
{
Queue<int> q;
ArduinoCIQueue<int> q;
int data[5] = {11, 22, 33, 44, 55};
for (int i = 0; i < 5; ++i) q.push(data[i]);

Queue<int> q2(q);
ArduinoCIQueue<int> q2(q);

for (int i = 0; i < 5; ++i) {
assertEqual(5 - i, q2.size());
Expand Down
6 changes: 3 additions & 3 deletions SampleProjects/TestSomething/test/table.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ void setResult3(long l, int k, int v) {

unittest(basic_table)
{
Table<String, int> t;
ArduinoCITable<String, int> t;
assertTrue(t.empty());

int data[5] = {11, 22, 33, 44, 55};
Expand All @@ -47,7 +47,7 @@ unittest(basic_table)
}

unittest(iteration_no_arg) {
Table<int, int> t;
ArduinoCITable<int, int> t;
for (int i = 0; i < 5; ++i) {
results[i] = 0;
t.add(i, 11 * (i + 1));
Expand All @@ -59,7 +59,7 @@ unittest(iteration_no_arg) {
}

unittest(iteration_one_arg) {
Table<int, int> t;
ArduinoCITable<int, int> t;
for (int i = 0; i < 5; ++i) {
results[i] = 0;
t.add(i, 11 * (i + 1));
Expand Down
14 changes: 7 additions & 7 deletions cpp/arduino/PinHistory.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@
template <typename T>
class PinHistory : public ObservableDataStream {
private:
Queue<T> qIn;
Queue<T> qOut;
ArduinoCIQueue<T> qIn;
ArduinoCIQueue<T> qOut;

void clear() {
qOut.clear();
qIn.clear();
}

// enqueue ascii bits
void a2q(Queue<T> &q, String input, bool bigEndian, bool advertise) {
void a2q(ArduinoCIQueue<T> &q, String input, bool bigEndian, bool advertise) {
// 8 chars at a time, form up
for (int j = 0; j < input.length(); ++j) {
for (int i = 0; i < 8; ++i) {
Expand All @@ -31,10 +31,10 @@ class PinHistory : public ObservableDataStream {

// convert a queue to a string as if it was serial bits
// start from offset, consider endianness
String q2a(const Queue<T> &q, unsigned int offset, bool bigEndian) const {
String q2a(const ArduinoCIQueue<T> &q, unsigned int offset, bool bigEndian) const {
String ret = "";

Queue<T> q2(q);
ArduinoCIQueue<T> q2(q);

while (offset) {
q2.pop();
Expand Down Expand Up @@ -135,7 +135,7 @@ class PinHistory : public ObservableDataStream {
// copy elements to an array, up to a given length
// return the number of elements moved
int toArray (T* arr, unsigned int length) const {
Queue<T> q2(qOut);
ArduinoCIQueue<T> q2(qOut);

int ret = 0;
for (int i = 0; i < length && q2.size(); ++i) {
Expand All @@ -149,7 +149,7 @@ class PinHistory : public ObservableDataStream {
// see if the array matches the elements in the queue
bool hasElements (T const * const arr, unsigned int length) const {
int i;
Queue<T> q2(qOut);
ArduinoCIQueue<T> q2(qOut);
for (i = 0; i < length && q2.size(); ++i) {
if (q2.front() != arr[i]) return false;
q2.pop();
Expand Down
2 changes: 1 addition & 1 deletion cpp/arduino/ci/DeviceUsingBytes.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
class DeviceUsingBytes : public DataStreamObserver {
public:
String mMessage;
Table<String, String> mResponses;
ArduinoCITable<String, String> mResponses;
GodmodeState* state;


Expand Down
2 changes: 1 addition & 1 deletion cpp/arduino/ci/ObservableDataStream.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class DataStreamObserver {
class ObservableDataStream
{
private:
Table<String, DataStreamObserver*> mObservers;
ArduinoCITable<String, DataStreamObserver*> mObservers;
bool mAdvertisingBit;
unsigned char mAdvertisingByte;

Expand Down
8 changes: 4 additions & 4 deletions cpp/arduino/ci/Queue.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#pragma once

template <typename T>
class Queue {
class ArduinoCIQueue {
private:
struct Node {
T data;
Expand All @@ -19,9 +19,9 @@ class Queue {
}

public:
Queue(): mNil() { init(); }
ArduinoCIQueue(): mNil() { init(); }

Queue(const Queue<T>& q) {
ArduinoCIQueue(const ArduinoCIQueue<T>& q) {
init();
for (Node* n = q.mFront; n; n = n->next) push(n->data);
}
Expand Down Expand Up @@ -69,5 +69,5 @@ class Queue {

void clear() { while (!empty()) pop(); }

~Queue() { clear(); }
~ArduinoCIQueue() { clear(); }
};
6 changes: 3 additions & 3 deletions cpp/arduino/ci/Table.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// this is this stupidest table implementation ever but it's
// an MVP for unit testing. O(n).
template <typename K, typename V>
class Table {
class ArduinoCITable {
private:
struct Node {
K key;
Expand All @@ -25,7 +25,7 @@ class Table {
}

public:
Table() : mNilK(), mNilV() { init(); }
ArduinoCITable() : mNilK(), mNilV() { init(); }

// number of things in the table
inline unsigned long size() const { return mSize; }
Expand Down Expand Up @@ -121,5 +121,5 @@ class Table {
}
}

~Table() { clear(); }
~ArduinoCITable() { clear(); }
};