{# carefree-objects
 #
 # a thread-safe object manager extension for c++
 #
 # Copyright (C) 2011-2014 Stefan Zimmermann <zimmermann.code@gmail.com>
 #
 # carefree-objects is free software: you can redistribute it and/or modify
 # it under the terms of the GNU Lesser General Public License as published by
 # the Free Software Foundation, either version 3 of the License, or
 # (at your option) any later version.
 #
 # carefree-objects 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 Lesser General Public License for more details.
 #
 # You should have received a copy of the GNU Lesser General Public License
 # along with carefree-objects.  If not, see <http://www.gnu.org/licenses/>.
 #}

{% macro enum(name) %}
  struct _{{ name }}
  {
    enum Enum
    {
      {{ caller() }}
    };
  };
  typedef typename _{{ name }}::Enum {{ name }};
{% endmacro %}

{% macro _method(pre_qualifiers, return_type, name, arg_types, post_qualifiers) %}
  {{ pre_qualifiers|join(' ') }} {{ return_type }} {{ name }}
  ({{ arg_types|join(', ') }})
    {{ post_qualifiers|join('\n') }}
    noexcept(!cfo_EXC)
  {
  {% if caller %}
    {{ caller() }}
  {% else %}
    return (*this)->{{ name }}();
  {% endif %}
  }
{% endmacro %}

{% macro method(return_type, name, arg_types) %}
  {{ _method([], return_type, name, arg_types, []) }}
{% endmacro %}

{% macro const_method(return_type, name, arg_types) %}
  {{ _method([], return_type, name, arg_types, ['const']) }}
{% endmacro %}

{% macro inline_method(return_type, name, arg_types) %}
  {{ _method(['inline'], return_type, name, arg_types, []) }}
{% endmacro %}

{% macro inline_const_method(return_type, name, arg_types) %}
  {{ _method(['inline'], return_type, name, arg_types, ['const']) }}
{% endmacro %}
