/*
 * Beautiful Capi generates beautiful C API wrappers for your C++ classes
 * Copyright (C) 2015 Petr Petrovich Petrov
 *
 * This file is part of Beautiful Capi.
 *
 * Beautiful Capi is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * Beautiful Capi is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Beautiful Capi.  If not, see <http://www.gnu.org/licenses/>.
 *
 */

/*
 * WARNING: This file was automatically generated by Beautiful Capi!
 * Do not edit this file! Please edit the source API description.
 */

#ifndef POINTSET_POINTS_DEFINITION_INCLUDED
#define POINTSET_POINTS_DEFINITION_INCLUDED

#include "PointSet/PointsDecl.h"
#include "PointSet/Position.h"

#ifdef __cplusplus

inline PointSet::PointsPtr::PointsPtr()
{
    SetObject(PointSet::PointsPtr(PointSet::PointsPtr::force_creating_from_raw_pointer, point_set_points_default(), false).Detach());
}

inline size_t PointSet::PointsPtr::Size() const
{
    return point_set_points_size_const(GetRawPointer());
}

inline void PointSet::PointsPtr::Reserve(size_t capacity)
{
    point_set_points_reserve(GetRawPointer(), capacity);
}

inline void PointSet::PointsPtr::Resize(size_t size, const PointSet::Position& default_value)
{
    point_set_points_resize(GetRawPointer(), size, default_value.GetRawPointer());
}

inline PointSet::Position PointSet::PointsPtr::GetElement(size_t index) const
{
    return PointSet::Position(PointSet::Position::force_creating_from_raw_pointer, point_set_points_get_element_const(GetRawPointer(), index), false);
}

inline void PointSet::PointsPtr::SetElement(size_t index, const PointSet::Position& value)
{
    point_set_points_set_element(GetRawPointer(), index, value.GetRawPointer());
}

inline void PointSet::PointsPtr::PushBack(const PointSet::Position& value)
{
    point_set_points_push_back(GetRawPointer(), value.GetRawPointer());
}

inline void PointSet::PointsPtr::Clear()
{
    point_set_points_clear(GetRawPointer());
}

inline PointSet::PointsPtr::PointsPtr(const PointsPtr& other)
{
    SetObject(other.GetRawPointer());
    if (other.GetRawPointer())
    {
        point_set_points_add_ref(other.GetRawPointer());
    }
}

#ifdef POINTSET_CPP_COMPILER_HAS_RVALUE_REFERENCES
inline PointSet::PointsPtr::PointsPtr(PointsPtr&& other)
{
    mObject = other.mObject;
    other.mObject = 0;
}
#endif /* POINTSET_CPP_COMPILER_HAS_RVALUE_REFERENCES */

inline PointSet::PointsPtr::PointsPtr(PointSet::PointsPtr::ECreateFromRawPointer, void *object_pointer, bool add_ref_object)
{
    SetObject(object_pointer);
    if (add_ref_object && object_pointer)
    {
        point_set_points_add_ref(object_pointer);
    }
}

inline PointSet::PointsPtr::~PointsPtr()
{
    if (GetRawPointer())
    {
        point_set_points_release(GetRawPointer());
        SetObject(0);
    }
}

inline PointSet::PointsPtr& PointSet::PointsPtr::operator=(const PointSet::PointsPtr& other)
{
    if (GetRawPointer() != other.GetRawPointer())
    {
        if (GetRawPointer())
        {
            point_set_points_release(GetRawPointer());
            SetObject(0);
        }
        SetObject(other.GetRawPointer());
        if (other.GetRawPointer())
        {
            point_set_points_add_ref(other.GetRawPointer());
        }
    }
    return *this;
}

#ifdef POINTSET_CPP_COMPILER_HAS_RVALUE_REFERENCES
inline PointSet::PointsPtr& PointSet::PointsPtr::operator=(PointSet::PointsPtr&& other)
{
    if (GetRawPointer() != other.GetRawPointer())
    {
        if (GetRawPointer())
        {
            point_set_points_release(GetRawPointer());
            SetObject(0);
        }
        mObject = other.mObject;
        other.mObject = 0;
    }
    return *this;
}
#endif /* POINTSET_CPP_COMPILER_HAS_RVALUE_REFERENCES */

inline PointSet::PointsPtr PointSet::PointsPtr::Null()
{
    return PointSet::PointsPtr(PointSet::PointsPtr::force_creating_from_raw_pointer, static_cast<void*>(0), false);
}

inline bool PointSet::PointsPtr::IsNull() const
{
    return !GetRawPointer();
}

inline bool PointSet::PointsPtr::IsNotNull() const
{
    return GetRawPointer() != 0;
}

inline bool PointSet::PointsPtr::operator!() const
{
    return !GetRawPointer();
}

inline void* PointSet::PointsPtr::Detach()
{
    void* result = GetRawPointer();
    SetObject(0);
    return result;
}

inline void* PointSet::PointsPtr::GetRawPointer() const
{
    return PointSet::PointsPtr::mObject ? mObject: 0;
}

inline PointSet::PointsPtr* PointSet::PointsPtr::operator->()
{
    return this;
}

inline const PointSet::PointsPtr* PointSet::PointsPtr::operator->() const
{
    return this;
}

inline void PointSet::PointsPtr::SetObject(void* object_pointer)
{
    mObject = object_pointer;
}

#endif /* __cplusplus */

#endif /* POINTSET_POINTS_DEFINITION_INCLUDED */

