nImO::Array::Array (void) : inherited1(), inherited2() { ODL_ENTER(); //#### ODL_EXIT_P(this); //#### } // nImO::Array::Array
nImO::Array::Array (const nImO::Array & other) : inherited1(), inherited2() { ODL_ENTER(); //#### ODL_P1("other = ", &other); //#### addEntries(other); ODL_EXIT_P(this); //#### } // nImO::Array::Array
const char * nImO::Array::getInitialCharacters (void) { ODL_ENTER(); //#### static const char initialChars[] = { kStartArrayChar, '\0' }; ODL_EXIT_S(initialChars); //#### return initialChars; } // nImO::Array::getInitialCharacters
const char * nImO::Array::getTerminalCharacters (void) { ODL_ENTER(); //#### static const char terminalChars[] = { kEndArrayChar, '\0' }; ODL_EXIT_S(terminalChars); //#### return terminalChars; } // nImO::Array::getTerminalCharacters
void nImO::Array::getExtractionInfo (DataKind & aByte, DataKind & aMask, nImO::Value::Extractor & theExtractor) { ODL_ENTER(); //#### ODL_P3("aByte = ", &aByte, "aMask = ", &aMask, "theExtractor = ", &theExtractor); //#### aByte = (DataKind::Other | DataKind::OtherContainerStart | DataKind::OtherContainerTypeArray); aMask = (DataKind::Mask | DataKind::OtherTypeMask | DataKind::OtherContainerTypeMask); theExtractor = extractValue; ODL_EXIT(); //#### } // nImO::Array::getExtractionInfo
nImO::Array & nImO::Array::addEntries (const nImO::Array & other) { ODL_ENTER(); //#### ODL_P1("other = ", &other); //#### for (auto & walker : other) { addValue(walker); } ODL_EXIT_P(this); //#### return *this; } // nImO::Array::addEntries
ServiceEntity::ServiceEntity(const PortPanel::EntityKind kind, const string & behaviour, const string & description, ServiceViewerApp & owner) : inherited(), _panel(kind, behaviour, description, owner, *this), _node(NULL), _drawConnectMarker(false), _drawDisconnectMarker(false), _drawMoveMarker(false), _selected(false) { ODL_ENTER(); //#### ODL_S2s("behaviour = ", behaviour, "description = ", description); //#### ODL_P1("owner = ", &owner); //#### ODL_EXIT_P(this); //#### } // ServiceEntity::ServiceEntity
void nImO::Array::writeToMessage (nImO::Message & outMessage) const { ODL_ENTER(); //#### ODL_P1("outMessage = ", &outMessage); //#### if (0 < inherited2::size()) { ODL_LOG("(0 < inherited2::size())"); //#### DataKind startArray = (DataKind::Other | DataKind::OtherContainerStart | DataKind::OtherContainerTypeArray | DataKind::OtherContainerNonEmptyValue); DataKind endArray = (DataKind::Other | DataKind::OtherContainerEnd | DataKind::OtherContainerTypeArray | DataKind::OtherContainerNonEmptyValue); std::queue<double> doublesSeen; outMessage.appendBytes(&startArray, sizeof(startArray)); writeInt64ToMessage(outMessage, static_cast<int>(inherited2::size()) + DataKindIntegerShortValueMinValue - 1); for (const_iterator walker(inherited2::begin()); inherited2::end() != walker; ++walker) { SpValue aValue(*walker); if (aValue) { // Check for sequences of Double values const Double * doubleValue = aValue->asDouble(); if (nullptr == doubleValue) { Double::writeValuesToMessage(doublesSeen, outMessage); aValue->writeToMessage(outMessage); } else { doublesSeen.push(doubleValue->getDoubleValue()); } } } // Write out any held Double values Double::writeValuesToMessage(doublesSeen, outMessage); outMessage.appendBytes(&endArray, sizeof(endArray)); } else { ODL_LOG("! (0 < inherited2::size())"); //#### static const DataKind stuff[] = { (DataKind::Other | DataKind::OtherContainerStart | DataKind::OtherContainerTypeArray | DataKind::OtherContainerEmptyValue), (DataKind::Other | DataKind::OtherContainerEnd | DataKind::OtherContainerTypeArray | DataKind::OtherContainerEmptyValue) }; outMessage.appendBytes(stuff, sizeof(stuff)); } ODL_EXIT(); //#### } // nImO::Array::writeToMessage
nImO::SpValue nImO::Array::readFromStringBuffer (const nImO::StringBuffer & inBuffer, size_t & position) { ODL_ENTER(); //#### ODL_P2("inBuffer = ", &inBuffer, "position = ", &position); //#### bool atEnd; bool done = false; bool valid = false; auto result = std::make_shared<Array>(); size_t localIndex = position; int aChar = inBuffer.getChar(localIndex++, atEnd); ODL_P1("result <- ", result.get()); //#### ODL_I1("localIndex <- ", localIndex); //#### ODL_C1("aChar <- ", aChar); //#### ODL_B1("atEnd <- ", atEnd); //#### if ((! atEnd) && (kStartArrayChar == aChar)) { for ( ; ! done; ) { // Skip whitespace for (aChar = inBuffer.getChar(localIndex, atEnd); (! atEnd) && isspace(aChar); aChar = inBuffer.getChar(++localIndex, atEnd)) { ODL_I1("localIndex <- ", localIndex); //#### ODL_C1("aChar <- ", aChar); //#### ODL_B1("atEnd <- ", atEnd); //#### } ODL_I1("localIndex = ", localIndex); //#### ODL_C1("aChar = ", aChar); //#### // Check for the closing bracket if (atEnd) { ODL_LOG("(atEnd)"); //#### done = true; } else if (kEndArrayChar == aChar) { done = valid = true; } else { SpValue element(Value::readFromStringBuffer(inBuffer, localIndex)); ODL_I1("localIndex <- ", localIndex); //#### if (nullptr == element) { ODL_LOG("(nullptr == element)"); //#### done = true; } else { result->addValue(element); } } } } else { ODL_LOG("! (kStartArrayChar == aChar)"); //#### } if (valid) { position = localIndex + 1; } else { ODL_LOG("! (valid)"); //#### result.reset(); } ODL_EXIT_P(result.get()); //#### return result; } // nImO::Array::readFromStringBuffer
nImO::SpValue nImO::Array::extractValue (const nImO::Message & theMessage, const int leadByte, size_t & position, nImO::SpArray parentValue) { ODL_ENTER(); //#### ODL_P3("theMessage = ", &theMessage, "position = ", &position, "parentValue = ", //#### parentValue.get()); //#### ODL_X1("leadByte = ", leadByte); //#### SpValue result; bool atEnd; bool isEmpty = (DataKind::OtherContainerEmptyValue == (DataKind::OtherContainerEmptyMask & leadByte)); int aByte; ++position; // We will always accept the lead byte ODL_I1("position <- ", position); //#### if (isEmpty) { ODL_LOG("(isEmpty)"); //#### aByte = theMessage.getByte(position, atEnd); ODL_X1("aByte <- ", aByte); //#### ODL_B1("atEnd <- ", atEnd); //#### if (! atEnd) { ODL_LOG("(! atEnd)"); //#### static const DataKind endMarker = (DataKind::Other | DataKind::OtherContainerEnd | DataKind::OtherContainerTypeArray | DataKind::OtherContainerEmptyValue); if (toUType(endMarker) == aByte) { ODL_LOG("(endMarker == aByte)"); //#### result.reset(new Array); ++position; ODL_I1("position <- ", position); //#### } else { ODL_LOG("! (endMarker == aByte)"); //#### result.reset(new Invalid("Empty Array with incorrect end tag @", position)); } } } else { ODL_LOG("! (isEmpty)"); //#### aByte = theMessage.getByte(position, atEnd); ODL_X1("aByte <- ", aByte); //#### ODL_B1("atEnd <- ", atEnd); //#### if (! atEnd) { ODL_LOG("(! atEnd)"); //#### IntStatus numStatus; int64_t elementCount = extractInt64FromMessage(theMessage, aByte, position, numStatus); if (IntStatus::Successful == numStatus) { ODL_LOG("(IntStatus::Successful == status)"); //#### elementCount -= DataKindIntegerShortValueMinValue - 1; ODL_I1("elementCount <- ", elementCount); //#### if (0 >= elementCount) { ODL_LOG("(0 >= elementCount)"); //#### result.reset(new Invalid("Array with zero or negative count @", position)); } else { auto anArray = std::make_shared<Array>(); result = anArray; if (nullptr == result) { ODL_LOG("(nullptr == result)"); //#### result.reset(new Invalid("Could not allocate an Array")); } else { bool okSoFar = true; for ( ; okSoFar && (elementCount > static_cast<int64_t>(anArray->size())); ) { aByte = theMessage.getByte(position, atEnd); ODL_X1("aByte <- ", aByte); //#### ODL_B1("atEnd <- ", atEnd); //#### if (atEnd) { ODL_LOG("(atEnd)"); //#### result.reset(); okSoFar = false; } else { SpValue aValue(getValueFromMessage(theMessage, position, aByte, anArray)); // Note that it is the responsibility of the extractor to add to // this Array, so it's not correct for this loop to perform an // append operation. if (nullptr == aValue) { ODL_LOG("(nullptr == aValue)"); //#### result.reset(new Invalid("Null Value read @", position)); okSoFar = false; } else if (aValue->asFlaw()) { ODL_LOG("(aValue->asFlaw())"); //#### result = aValue; okSoFar = false; } } } if (okSoFar) { aByte = theMessage.getByte(position, atEnd); ODL_X1("aByte <- ", aByte); //#### ODL_B1("atEnd <- ", atEnd); //#### if (atEnd) { ODL_LOG("(atEnd)"); //#### result.reset(); okSoFar = false; } else { ODL_LOG("! (atEnd)"); //#### static const DataKind endMarker = (DataKind::Other | DataKind::OtherContainerEnd | DataKind::OtherContainerTypeArray | DataKind::OtherContainerNonEmptyValue); if (toUType(endMarker) == aByte) { ODL_LOG("(toUType(endMarker) == aByte)"); //#### ++position; ODL_I1("position <- ", position); //#### } else { ODL_LOG("! (toUType(endMarker) == aByte)"); //#### result.reset(new Invalid("Non-empty Array with incorrect end " "tag @", position)); } } } } } } else { ODL_LOG("! (IntStatus::Successful == numStatus)"); //#### } } } if ((nullptr != parentValue) && (nullptr != result) && (! result->asFlaw())) { ODL_LOG("((nullptr != parentValue) && (nullptr != result) && (! result->asFlaw()))"); //#### parentValue->addValue(result); } ODL_EXIT_P(result.get()); //#### return result; } // nImO::Array::extractValue
MovementTracker::MovementTracker(void) { ODL_ENTER(); //#### ODL_EXIT_P(this); //#### } // MovementTracker::MovementTracker