mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-19 00:37:25 +01:00
[apps/shared] Move function store class to shared/ to be used by
sequence Change-Id: I89380d59e3450e9c5af4bf05f520ed1a5205ba29
This commit is contained in:
65
apps/shared/function_store.cpp
Normal file
65
apps/shared/function_store.cpp
Normal file
@@ -0,0 +1,65 @@
|
||||
#include "function_store.h"
|
||||
#include <assert.h>
|
||||
|
||||
namespace Shared {
|
||||
|
||||
FunctionStore::FunctionStore() :
|
||||
m_numberOfFunctions(0)
|
||||
{
|
||||
}
|
||||
|
||||
Function * FunctionStore::activeFunctionAtIndex(int i) {
|
||||
assert(i>=0 && i<m_numberOfFunctions);
|
||||
int index = 0;
|
||||
for (int k = 0; k < m_numberOfFunctions; k++) {
|
||||
if (functionAtIndex(k)->isActive() && functionAtIndex(k)->layout() != nullptr) {
|
||||
if (i == index) {
|
||||
return functionAtIndex(k);
|
||||
}
|
||||
index++;
|
||||
}
|
||||
}
|
||||
assert(false);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Function * FunctionStore::definedFunctionAtIndex(int i) {
|
||||
assert(i>=0 && i<m_numberOfFunctions);
|
||||
int index = 0;
|
||||
for (int k = 0; k < m_numberOfFunctions; k++) {
|
||||
if (functionAtIndex(k)->layout() != nullptr) {
|
||||
if (i == index) {
|
||||
return functionAtIndex(k);
|
||||
}
|
||||
index++;
|
||||
}
|
||||
}
|
||||
assert(false);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
int FunctionStore::numberOfFunctions() {
|
||||
return m_numberOfFunctions;
|
||||
}
|
||||
|
||||
int FunctionStore::numberOfActiveFunctions() {
|
||||
int result = 0;
|
||||
for (int i = 0; i < m_numberOfFunctions; i++) {
|
||||
if (functionAtIndex(i)->layout() != nullptr && functionAtIndex(i)->isActive()) {
|
||||
result++;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
int FunctionStore::numberOfDefinedFunctions() {
|
||||
int result = 0;
|
||||
for (int i = 0; i < m_numberOfFunctions; i++) {
|
||||
if (functionAtIndex(i)->layout() != nullptr) {
|
||||
result++;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user