summaryrefslogtreecommitdiffstats
path: root/o3d/plugin/idl/param_array.idl
blob: 63156d48bfe79692287dd8b2272f67b1f730776d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
/*
 * Copyright 2009, Google Inc.
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are
 * met:
 *
 *     * Redistributions of source code must retain the above copyright
 * notice, this list of conditions and the following disclaimer.
 *     * Redistributions in binary form must reproduce the above
 * copyright notice, this list of conditions and the following disclaimer
 * in the documentation and/or other materials provided with the
 * distribution.
 *     * Neither the name of Google Inc. nor the names of its
 * contributors may be used to endorse or promote products derived from
 * this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

namespace o3d {

%[
  A ParamArray is an object that holds an array of Params.
%]

[nocpp, include="core/cross/param_array.h"] class ParamArray
    : NamedObject {

  %[
    Creates a Param of the given type at the index requested. If a Param
    already exists at that index the new param will be replace it. If the
    index is past the end of the current array params of the requested type
    will be created to fill out the array to the requested index.

    \param index index at which to create new param.
    \param param_type_name The type of Param to create. For a list of valid
       types see ParamObject.createParam
    \return Param created at index or null if failure.

  %]
  [userglue] Param? CreateParam(unsigned int index, String param_type_name);

  %[
    Gets a Param by index.

    \param index Index of Param to get.
    \return The Param at index, or null if out of range.
  %]
  [userglue, const] Param? GetParam(unsigned int index);

  %[
    Removes a range of params.

    \param start_index Index of first param to remove.
    \param num_to_remove The number of params to remove starting at start_index.
  %]
  void RemoveParams(unsigned int start_index, unsigned int num_to_remove);

  %[
    Resizes the array.

    \param num_params The number of params to make the array.
    \param param_type_name The type of Param to create if resizing
       requires params to be created.  For a list of valid types see
       ParamObject.createParam
  %]
  [userglue] void Resize(unsigned int num_params, String param_type_name);

  %[
    Gets all the param on this param object.

    Each access to this field gets the entire list, so it is best to get it
    just once. For example:
    \code
    var params = ParamArray.params;
    for (var i = 0; i < params.length; i++) {
      var param = params[i];
    }
    \endcode

    Note that modifications to this array [e.g. push()] will not affect
    the underlying ParamObject, while modifications to the array's members
    <strong>will</strong> affect them.
  %]
  [userglue_getter, getter] ParamVector params_;

  %[
    Returns the number of parameters in this ParamArray.
  %]
  [userglue_getter, getter] unsigned int length;

  [verbatim=cpp_glue] %{
    o3d::ParamVector userglue_getter_params_(
      o3d::ParamArray *self) {
      const o3d::ParamArray::ParamRefVector& src_params = self->params();
      o3d::ParamVector params(src_params.size());
      for (unsigned ii = 0; ii < src_params.size(); ++ii) {
        params[ii] = src_params[ii];
      }
      return params;
    }
    unsigned int userglue_getter_length(
      o3d::ParamArray *self) {
      return self->size();
    }
    o3d::Param* userglue_method_CreateParam(
        o3d:: ParamArray *self,
        unsigned int index,
        const o3d::String& param_type_name) {
      return self->CreateParamByClassName(index, param_type_name);
    }
    void userglue_method_Resize(
        o3d:: ParamArray *self,
        unsigned int num_params,
        const o3d::String& param_type_name) {
      self->ResizeByClassName(num_params, param_type_name);
    }
    o3d::Param* userglue_method_GetParam(
        o3d:: ParamArray *self,
        unsigned int index) {
      return self->GetUntypedParam(index);
    }
  %}

};  // ParamArray

%[
  A Param which stores a ParamArray.
%]
[nocpp, include="core/cross/param.h"] class ParamParamArray : Param {
  %[
    The ParamArray stored by the Param.
  %]
  [getter, setter] ParamArray value_;
};

}  // namespace o3d