| 1 | #include "Library/Nerve/NerveActionCtrl.h" |
|---|---|
| 2 | |
| 3 | #include "Library/Base/StringUtil.h" |
| 4 | #include "Library/Nerve/NerveAction.h" |
| 5 | #include "Library/Nerve/NerveUtil.h" |
| 6 | |
| 7 | namespace al { |
| 8 | |
| 9 | NerveActionCtrl::NerveActionCtrl(alNerveFunction::NerveActionCollector* collector) { |
| 10 | mNumActions = collector->getNumActions(); |
| 11 | mActions = new NerveAction*[mNumActions]; |
| 12 | |
| 13 | if (mNumActions > 0) { |
| 14 | NerveAction* current = collector->getHead(); |
| 15 | mActions[0] = current; |
| 16 | |
| 17 | for (s32 i = 1; i < mNumActions; ++i) { |
| 18 | // requires doing this pattern to calculate mActions[i] first |
| 19 | NerveAction** next = &mActions[i]; |
| 20 | current = current->getNext(); |
| 21 | *next = current; |
| 22 | } |
| 23 | } |
| 24 | } |
| 25 | |
| 26 | NerveAction* NerveActionCtrl::findNerve(const char* name) const { |
| 27 | for (s32 i = 0; i < mNumActions; ++i) { |
| 28 | NerveAction* action = mActions[i]; |
| 29 | if (isEqualString(str1: action->getActionName(), str2: name)) |
| 30 | return action; |
| 31 | } |
| 32 | |
| 33 | return nullptr; |
| 34 | } |
| 35 | |
| 36 | } // namespace al |
| 37 |