Graphite  Version 3
An experimental 3D geometry processing program
vector.h
1 /*
2  * OGF/Graphite: Geometry and Graphics Programming Library + Utilities
3  * Copyright (C) 2000 Bruno Levy
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18  *
19  * If you modify this software, you should include a notice giving the
20  * name of the person performing the modification, the date of modification,
21  * and the reason for such modification.
22  *
23  * Contact: Bruno Levy
24  *
25  * levy@loria.fr
26  *
27  * ISA Project
28  * LORIA, INRIA Lorraine,
29  * Campus Scientifique, BP 239
30  * 54506 VANDOEUVRE LES NANCY CEDEX
31  * FRANCE
32  *
33  * Note that the GNU General Public License does not permit incorporating
34  * the Software into proprietary programs.
35  */
36 
37 #ifndef H_OGF_SCENE_GRAPH_NL_VECTOR_H
38 #define H_OGF_SCENE_GRAPH_NL_VECTOR_H
39 
41 #include <OGF/gom/types/object.h>
43 
44 namespace OGF {
45 
46  class Grob;
47 
48  namespace NL {
49 
53  gom_class SCENE_GRAPH_API Vector :
54  public Object, public AttributeStoreObserver {
55 
56  public:
65  index_t size=0, index_t dimension=1,
66  MetaType* element_meta_type=nullptr
67  );
68 
76  Vector(Grob* grob, AttributeStore* attribute_store);
77 
89  Grob* grob, void* data, index_t size, index_t dimension,
90  MetaType* element_meta_type, bool read_only
91  );
92 
96  ~Vector() override;
97 
103  void get_element(index_t i, Any& value) const override;
104 
110  void set_element(index_t i, const Any& value) override;
111 
118  return base_addr_;
119  }
120 
126  double* data_double() const;
127 
134 
135  gom_properties:
136 
140  index_t get_nb_elements() const override {
141  return nb_elements();
142  }
143 
149  return dimension();
150  }
151 
156  index_t get_size() const {
157  return size();
158  }
159 
165  return element_meta_type_;
166  }
167 
173  bool get_read_only() const {
174  return read_only_;
175  }
176 
177  gom_slots:
178 
187  virtual void resize(
188  index_t new_size, index_t new_dim=1,
189  MetaType* element_meta_type=nullptr
190  );
191 
192  protected:
193 
200  bool check_index(index_t i) const;
201 
202  private:
203  size_t element_size_;
204  MetaType* element_meta_type_;
205  bool owns_memory_;
206  Grob* grob_;
207  AttributeStore* attribute_store_;
208  bool read_only_;
209  };
210 
211  /**********************************************************/
212 
213  }
214 }
215 
216 #endif
217 
Generic mechanism for attributes.
Base class for attributes. They are notified whenever the AttributeStore is modified.
Definition: attributes.h:70
Notifies a set of AttributeStoreObservers each time the stored array changes size and/or base address...
Definition: attributes.h:195
A class that stores a variable of arbitrary type.
Definition: any.h:62
Base class for all 3D Graphite objects.
Definition: grob.h:68
The representation of a type in the Meta repository.
Definition: meta_type.h:221
A scriptable Vector objects.
Definition: vector.h:54
bool check_index(index_t i) const
Tests whether index i is valid.
Vector(Grob *grob, void *data, index_t size, index_t dimension, MetaType *element_meta_type, bool read_only)
Vector constructor.
bool get_read_only() const
Tests whether this Vector is read-only.
Definition: vector.h:173
void set_element(index_t i, const Any &value) override
Sets an element.
index_t * data_index_t() const
Gets the data pointer as index_t.
MetaType * get_element_meta_type() const
Gets the MetaType of the elements.
Definition: vector.h:164
index_t get_dimension() const
Gets the dimension.
Definition: vector.h:148
Vector(Grob *grob, AttributeStore *attribute_store)
Vector constructor.
Vector(index_t size=0, index_t dimension=1, MetaType *element_meta_type=nullptr)
Vector constructor.
void get_element(index_t i, Any &value) const override
Gets an element.
Memory::pointer data() const
Gets the data pointer.
Definition: vector.h:117
~Vector() override
Vector destructor.
double * data_double() const
Gets the data pointer as doubles.
index_t get_size() const
Gets the size.
Definition: vector.h:156
Base class for all objects in the GOM system.
Definition: object.h:65
byte * pointer
Pointer to unsigned byte(s)
Definition: memory.h:104
geo_index_t index_t
The type for storing and manipulating indices.
Definition: numeric.h:329
Global Graphite namespace.
Definition: common.h:76
The base class for all objects in the GOM system.
Definitions common to all include files in the scene_graph library.