/*
 * SPDX-FileCopyrightText: 2006-2021 Istituto Italiano di Tecnologia (IIT)
 * SPDX-License-Identifier: BSD-3-Clause
 */

// Autogenerated by Thrift Compiler (0.14.1-yarped)
//
// This is an automatically generated file.
// It could get re-generated if the ALLOW_IDL_GENERATION flag is on.

#ifndef YARP_THRIFT_GENERATOR_STRUCT_MOBILEBASEVELOCITY_H
#define YARP_THRIFT_GENERATOR_STRUCT_MOBILEBASEVELOCITY_H

#include <yarp/dev/api.h>

#include <yarp/os/Wire.h>
#include <yarp/os/idl/WireTypes.h>

namespace yarp {
namespace dev {

class YARP_dev_API MobileBaseVelocity :
        public yarp::os::idl::WirePortable
{
public:
    // Fields
    /**
     * velocity of the robot [m/s]
     */
    double vel_x;
    /**
     * velocity of the robot [m/s]
     */
    double vel_y;
    /**
     * angular velocity of the robot [deg/s]
     */
    double vel_theta;

    // Default constructor
    MobileBaseVelocity();

    // Constructor with field values
    MobileBaseVelocity(const double vel_x,
                       const double vel_y,
                       const double vel_theta);

    // Read structure on a Wire
    bool read(yarp::os::idl::WireReader& reader) override;

    // Read structure on a Connection
    bool read(yarp::os::ConnectionReader& connection) override;

    // Write structure on a Wire
    bool write(const yarp::os::idl::WireWriter& writer) const override;

    // Write structure on a Connection
    bool write(yarp::os::ConnectionWriter& connection) const override;

    // Convert to a printable string
    std::string toString() const;

    // If you want to serialize this class without nesting, use this helper
    typedef yarp::os::idl::Unwrapped<MobileBaseVelocity> unwrapped;

    class Editor :
            public yarp::os::Wire,
            public yarp::os::PortWriter
    {
    public:
        // Editor: default constructor
        Editor();

        // Editor: constructor with base class
        Editor(MobileBaseVelocity& obj);

        // Editor: destructor
        ~Editor() override;

        // Editor: Deleted constructors and operator=
        Editor(const Editor& rhs) = delete;
        Editor(Editor&& rhs) = delete;
        Editor& operator=(const Editor& rhs) = delete;
        Editor& operator=(Editor&& rhs) = delete;

        // Editor: edit
        bool edit(MobileBaseVelocity& obj, bool dirty = true);

        // Editor: validity check
        bool isValid() const;

        // Editor: state
        MobileBaseVelocity& state();

        // Editor: start editing
        void start_editing();

#ifndef YARP_NO_DEPRECATED // Since YARP 3.2
        YARP_DEPRECATED_MSG("Use start_editing() instead")
        void begin()
        {
            start_editing();
        }
#endif // YARP_NO_DEPRECATED

        // Editor: stop editing
        void stop_editing();

#ifndef YARP_NO_DEPRECATED // Since YARP 3.2
        YARP_DEPRECATED_MSG("Use stop_editing() instead")
        void end()
        {
            stop_editing();
        }
#endif // YARP_NO_DEPRECATED

        // Editor: vel_x field
        void set_vel_x(const double vel_x);
        double get_vel_x() const;
        virtual bool will_set_vel_x();
        virtual bool did_set_vel_x();

        // Editor: vel_y field
        void set_vel_y(const double vel_y);
        double get_vel_y() const;
        virtual bool will_set_vel_y();
        virtual bool did_set_vel_y();

        // Editor: vel_theta field
        void set_vel_theta(const double vel_theta);
        double get_vel_theta() const;
        virtual bool will_set_vel_theta();
        virtual bool did_set_vel_theta();

        // Editor: clean
        void clean();

        // Editor: read
        bool read(yarp::os::ConnectionReader& connection) override;

        // Editor: write
        bool write(yarp::os::ConnectionWriter& connection) const override;

    private:
        // Editor: state
        MobileBaseVelocity* obj;
        bool obj_owned;
        int group;

        // Editor: dirty variables
        bool is_dirty;
        bool is_dirty_vel_x;
        bool is_dirty_vel_y;
        bool is_dirty_vel_theta;
        int dirty_count;

        // Editor: send if possible
        void communicate();

        // Editor: mark dirty overall
        void mark_dirty();

        // Editor: mark dirty single fields
        void mark_dirty_vel_x();
        void mark_dirty_vel_y();
        void mark_dirty_vel_theta();

        // Editor: dirty_flags
        void dirty_flags(bool flag);
    };

private:
    // read/write vel_x field
    bool read_vel_x(yarp::os::idl::WireReader& reader);
    bool write_vel_x(const yarp::os::idl::WireWriter& writer) const;
    bool nested_read_vel_x(yarp::os::idl::WireReader& reader);
    bool nested_write_vel_x(const yarp::os::idl::WireWriter& writer) const;

    // read/write vel_y field
    bool read_vel_y(yarp::os::idl::WireReader& reader);
    bool write_vel_y(const yarp::os::idl::WireWriter& writer) const;
    bool nested_read_vel_y(yarp::os::idl::WireReader& reader);
    bool nested_write_vel_y(const yarp::os::idl::WireWriter& writer) const;

    // read/write vel_theta field
    bool read_vel_theta(yarp::os::idl::WireReader& reader);
    bool write_vel_theta(const yarp::os::idl::WireWriter& writer) const;
    bool nested_read_vel_theta(yarp::os::idl::WireReader& reader);
    bool nested_write_vel_theta(const yarp::os::idl::WireWriter& writer) const;
};

} // namespace yarp
} // namespace dev

#endif // YARP_THRIFT_GENERATOR_STRUCT_MOBILEBASEVELOCITY_H
