// ====================================================================== // \title AArrayAc.cpp // \author Generated by fpp-to-cpp // \brief cpp file for A array // ====================================================================== #include "AArrayAc.hpp" #include "Fw/Types/Assert.hpp" // ---------------------------------------------------------------------- // Constructors // ---------------------------------------------------------------------- A :: A() : Serializable() { // Construct using element-wise constructor *this = A( 0, 0, 0 ); } A :: A(const ElementType (&a)[SIZE]) : Serializable() { for (U32 index = 0; index < SIZE; index++) { this->elements[index] = a[index]; } } A :: A(const ElementType& e) : Serializable() { for (U32 index = 0; index < SIZE; index++) { this->elements[index] = e; } } A :: A( const ElementType& e1, const ElementType& e2, const ElementType& e3 ) : Serializable() { this->elements[0] = e1; this->elements[1] = e2; this->elements[2] = e3; } A :: A(const A& obj) : Serializable() { for (U32 index = 0; index < SIZE; index++) { this->elements[index] = obj.elements[index]; } } // ---------------------------------------------------------------------- // Operators // ---------------------------------------------------------------------- A::ElementType& A :: operator[](const U32 i) { FW_ASSERT(i < SIZE, static_cast(i), static_cast(SIZE)); return this->elements[i]; } const A::ElementType& A :: operator[](const U32 i) const { FW_ASSERT(i < SIZE, static_cast(i), static_cast(SIZE)); return this->elements[i]; } A& A :: operator=(const A& obj) { if (this == &obj) { return *this; } for (U32 index = 0; index < SIZE; index++) { this->elements[index] = obj.elements[index]; } return *this; } A& A :: operator=(const ElementType (&a)[SIZE]) { for (U32 index = 0; index < SIZE; index++) { this->elements[index] = a[index]; } return *this; } A& A :: operator=(const ElementType& e) { for (U32 index = 0; index < SIZE; index++) { this->elements[index] = e; } return *this; } bool A :: operator==(const A& obj) const { for (U32 index = 0; index < SIZE; index++) { if (!((*this)[index] == obj[index])) { return false; } } return true; } bool A :: operator!=(const A& obj) const { return !(*this == obj); } #ifdef BUILD_UT std::ostream& operator<<(std::ostream& os, const A& obj) { Fw::String s; obj.toString(s); os << s; return os; } #endif // ---------------------------------------------------------------------- // Public member functions // ---------------------------------------------------------------------- Fw::SerializeStatus A :: serialize(Fw::SerializeBufferBase& buffer) const { Fw::SerializeStatus status = Fw::FW_SERIALIZE_OK; for (U32 index = 0; index < SIZE; index++) { status = buffer.serialize((*this)[index]); if (status != Fw::FW_SERIALIZE_OK) { return status; } } return status; } Fw::SerializeStatus A :: deserialize(Fw::SerializeBufferBase& buffer) { Fw::SerializeStatus status = Fw::FW_SERIALIZE_OK; for (U32 index = 0; index < SIZE; index++) { status = buffer.deserialize((*this)[index]); if (status != Fw::FW_SERIALIZE_OK) { return status; } } return status; } #if FW_ARRAY_TO_STRING void A :: toString(Fw::StringBase& sb) const { static const char *formatString = "[ " "%" PRIu32 " " "%" PRIu32 " " "%" PRIu32 " ]"; sb.format( formatString, this->elements[0], this->elements[1], this->elements[2] ); } #endif