libmoldeo (Moldeo 1.0 Core)  1.0
libmoldeo es el conjunto de objetos y funciones, que permiten ejecutar las operaciones básicas de la plataforma Moldeo, y que compone su núcleo.
 Todo Clases Namespaces Archivos Funciones Variables 'typedefs' Enumeraciones Valores de enumeraciones Amigas 'defines' Grupos Páginas
moValue.h
Ir a la documentación de este archivo.
1 /*******************************************************************************
2 
3  moValue.h
4 
5  ****************************************************************************
6  * *
7  * This source is free software; you can redistribute it and/or modify *
8  * it under the terms of the GNU General Public License as published by *
9  * the Free Software Foundation; either version 2 of the License, or *
10  * (at your option) any later version. *
11  * *
12  * This code is distributed in the hope that it will be useful, but *
13  * WITHOUT ANY WARRANTY; without even the implied warranty of *
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
15  * General Public License for more details. *
16  * *
17  * A copy of the GNU General Public License is available on the World *
18  * Wide Web at <http://www.gnu.org/copyleft/gpl.html>. You can also *
19  * obtain it by writing to the Free Software Foundation, *
20  * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
21  * *
22  ****************************************************************************
23 
24  Copyright(C) 2006 Fabricio Costa
25 
26  Authors:
27  Fabricio Costa
28 
29 
30 *******************************************************************************/
31 
32 /*
33 NOTES:
34 
35  m_Config.GetParam( paramindex ).GetValue( valueindex ).GetSubValue( );
36 
37  m_Config.GetParam( paramindex ).GetValue( valueindex ).GetSubValue( );
38 
39  moXmlConfig
40  +moXmlParam
41  +moXmlValue
42  +moXmlSubValue
43  +moXmlSubValue
44  +moXmlSubValue
45  +moXmlValue
46  +moXmlSubValue
47  +moXmlSubValue
48  +moXmlParam
49  +moXmlValue
50  +moXmlSubValue
51  +moXmlParam
52  +moXmlValue
53  +moXmlSubValue
54  +moXmlSubValue
55  +moXmlValue
56  +moXmlSubValue
57 
58 */
59 
60 #ifndef __MO_VALUE_H__
61 #define __MO_VALUE_H__
62 
63 #include "moTypes.h"
64 #include "moTempo.h"
65 #include "moText.h"
66 #include "moArray.h"
67 #include "moMathMatrix.h"
68 #include "moMathFunction.h"
69 #include "moMathVector.h"
70 #include "moMathVector3.h"
71 #include "moMathVector4.h"
72 #include "moTextFilterParam.h"
73 
74 #include <iostream>
75 #include <map>
76 #include <string>
77 using namespace std;
78 
79 #define moRound(x) ((x) < (LONG_MIN-0.5) || (x) > (LONG_MAX+0.5)) ?\
80 0.0f : ((x)>=0?(long)((x)+0.5):(long)((x)-0.5))
81 
82 class moFont;
83 class moSceneNode;
84 class moTexture;
85 class moTextureFilter;
86 class moTextureBuffer;
87 class moVideoBuffer;
88 class moTextFilterParam;
89 class moSound;
90 
98 enum moDataType {
108  MO_DATA_POINTER,//may be a pointer to struct or to class
109  MO_DATA_VECTOR2I,//array of values
110  MO_DATA_VECTOR3I,//array of values
111  MO_DATA_VECTOR4I,//array of values
112  MO_DATA_VECTOR2F,//array of values
113  MO_DATA_VECTOR3F,//array of values
114  MO_DATA_VECTOR4F,//array of values
115  MO_DATA_IMAGESAMPLE,//pointer to an imagesample pointer
116  MO_DATA_IMAGESAMPLE_FILTERED,//pointer to a TextureFilter
117  MO_DATA_IMAGESAMPLE_TEXTUREBUFFER,//pointer to a texturebuffer pointer
118  MO_DATA_SOUNDSAMPLE,//pointer to a soundsample pointer
119  MO_DATA_VIDEOSAMPLE,//pointer to a videosample pointer: video buffer
122  MO_DATA_TEXT,//text,
125 };
126 
133 union moNumber {
140 };
141 
142 
149 class moDatas;
150 
151 typedef moDatas moDataMessage;
152 
153 class moDataMessages;
154 
156 
157  public:
158  moData();
159  moData( MOchar data );
160  moData( MOint data);
161  moData( MOlonglong data);
162  moData( MOdouble data);
163  moData( MOfloat data);
164  moData( MOpointer data , MOulong size, moDataType type );
165  moData( moText data );
166  moData( moDataType datatype );
167  virtual ~moData();
168 
169  moData& operator = ( const moData& data);
170  void Copy( const moData& data );
171 
172  bool IsValid() const;
173 
174  void SetFloat( MOfloat pfloat );
175  void SetDouble( MOdouble pdouble );
176  void SetInt( MOint pint );
177  void SetLong( MOlonglong plong );
178  void SetChar( MOchar pchar );
179  void SetPointer( MOpointer data, MOulong size );
180  void SetText( moText ptext );
181  void SetNumber( moNumber p_number );
182  void SetType( moDataType p_DataType );
183  void SetSize( MOulong p_DataSize );
184  void SetFun( const moText& p_functionExpression );
185 
187 
191  void SetFun( moMathFunction* p_Function );
192  void SetTexture( moTexture* p_Texture );
193  void SetTextureBuffer( moTextureBuffer* p_TextureBuffer );
194  void SetVideoBuffer( moVideoBuffer* p_VideoBuffer );
195  void SetTextureFilter( moTextureFilter* p_TextureFilter );
196  void SetTextureFilterAlpha( moData* p_alpha );
197  void SetTextureFilterParam( const moTextFilterParam &p_filterparam );
198  void SetFont( moFont* p_Font );
199  void SetModel( moSceneNode* p_Model );
200  void SetSound( moSound* p_Sound );
201  void SetVector( moVector2d *p_vector2d );
202  void SetVector( moVector3d *p_vector3d );
203  void SetVector( moVector4d *p_vector4d );
204  void SetVector( moVector2i *p_vector2i );
205  void SetVector( moVector3i *p_vector3i );
206  void SetVector( moVector4i *p_vector4i );
207 
208  void SetMessage( moDataMessage* p_datamessage );
209  void SetMessages( moDataMessages* p_datamessages );
215  moText Text();
216  MOint Int() const;
217  MOlonglong Long() const;
218  MOfloat Float() const;
219  MOdouble Double() const;
220  MOchar Char() const;
221  moNumber Number();
222  MOpointer Pointer();
223  moDataType Type() const;
224  MOulong Size() const;
225  MOdouble Eval();
226  MOdouble Eval( double x );
227  MOdouble LastEval() const;
228 
230  moMathFunction* Fun();
231  moFont* Font();
232  moTextureBuffer* TextureBuffer();
233  moSceneNode* Model();
234  moVector2d* Vector2d();
235  moVector2i* Vector2i();
236  moVector3d* Vector3d();
237  moVector3i* Vector3i();
238  moVector4d* Vector4d();
239  moVector4i* Vector4i();
240  moDataMessage* Message();
241  moDataMessages* Messages();
242  moSound* Sound();
243  moTexture* Texture();
244  moTexture* TextureDestination();
245 
246  moData* GetData();
247 
248  //conversion
249  moText ToText() const;
250  static moText TypeToText( moDataType p_data_type );
251  moText TypeToText();
252  moDataType TextToType( moText texttype );
253 
254 
255  GLint GetGLId( MOfloat p_cycle, MOfloat p_fade, const moTextFilterParam &p_filterparam);
256  GLint GetGLId( moTempo *p_tempo, MOfloat p_fade, const moTextFilterParam &p_filterparam );
257  GLint GetGLId( MOuint p_i, MOfloat p_fade, const moTextFilterParam &p_filterparam );
258  GLint GetGLId( MOfloat p_fade, const moTextFilterParam &p_filterparam );
259  GLint GetGLId( moMoldeoObject* p_mob, MOfloat p_fade, const moTextFilterParam &p_filterparam );
260  GLint GetGLId( moMoldeoObject* p_mob, moTempo *p_tempo, MOfloat p_fade, const moTextFilterParam &p_filterparam );
261  GLint GetGLId( MOfloat p_cycle);
262  GLint GetGLId( moTempo *p_tempo );
263  GLint GetGLId( MOuint p_i);
264  GLint GetGLId();
265  GLint GetGLId( moMoldeoObject* p_mob );
266  GLint GetGLId( moMoldeoObject* p_mob, moTempo *p_tempo );
267 
268 
269  protected:
274 
275 
281 
283 
284 };
285 
286 
287 
290 typedef std::map< std::string, moData > moAttributes;
291 
292 
301  MO_VALUE_NUM,//cualquier número
303  MO_VALUE_NUM_INT,//entero 32b
304  MO_VALUE_NUM_LONG,//entero largo 64b
305  MO_VALUE_NUM_FLOAT,//coma flotante 32b
306  MO_VALUE_NUM_DOUBLE,//coma flotante precision doble
307  MO_VALUE_MATRIX,//any type of VECTOR
308  MO_VALUE_TXT,//any type of text, single or multiline
309  MO_VALUE_LNK,//link to a file, text is interpreted as relative, absolute link to a file
310  MO_VALUE_FUNCTION,//function parameter value, with lots of attributes....
311  MO_VALUE_XML,//text, xml formatted...
313 };
314 
315 
322 struct moValueIndex {
325 };
326 
327 
329 
330 
338 {
339  public:
342  virtual ~moValueDefinition();
343 
345 
346  void SetType( moValueType p2_type );
347  void SetIndex( MOint p_index );
348  moValueType GetType() const;
349  static moValueType ValueTypeFromStr( const moText& p_value_type_str );
350  moText GetTypeStr() const;
351  MOint GetIndex() const;
352 
353  moText GetCodeName() const;
354  void SetCodeName( moText p_codename );
355  void SetRange( MOfloat min, MOfloat max );
356  void SetRange( moText min, moText max );
357 
358  void GetRange( MOfloat* min, MOfloat* max);
359 
360  moText GetAttribute() const;
361  void SetAttribute( moText p_attribute );
362 
363  bool IsValid() const;
364  int Set( const moText& p_XmlText );
365  const moText& ToJSON();
366  const moText& ToXML();
367 
368  private:
369  moValueType m_Type;
370  MOint m_Index;
371  moText m_CodeName;
372  MOfloat m_Min,m_Max;
373 
374  moText m_Attribute; //for future use
375  moText m_FullJSON;
376  moText m_FullXML;
377 
378 };
379 
388 {
389  public:
391 
393  moValueBase();
394  moValueBase(const moValueBase &src);
395  virtual ~moValueBase();
396 
397  moValueBase &operator = (const moValueBase &src);
398 
400 
405  void SetValueDefinition( moValueDefinition& p_valuedefinition) {
406  m_ValueDefinition = p_valuedefinition;
407  }
408 
410 
416  return m_ValueDefinition;
417  }
418 
420 
423  void SetType( moValueType p_type );
424 
426 
429  moValueType GetType() const;
430 
432 
435  void SetIndex( MOint p_index );
436 
438 
442  moText GetTypeStr() const;
443 
445 
449  MOint GetIndex() const;
450 
452 
456  moText GetCodeName() const;
457 
459 
463  void SetCodeName( moText p_codename );
464 
465 
466  void SetRange( MOfloat min, MOfloat max );
467  void SetRange( moText min, moText max );
468 
469  void GetRange( MOfloat* min, MOfloat* max);
470 
471  moText GetAttribute() const;
472  void SetAttribute( moText p_attribute );
473 
474  const moText& ToJSON();
475  const moText& ToXML();
476  int Set( const moText& p_XmlText );
477 
478  bool FixType( moValueType p_ValueType );
479  private:
480 
482  moValueDefinition m_ValueDefinition;
483  moText m_FullJSON;
484  moText m_FullXML;
485 };
486 
487 
489 
490 
492 
502 {
503  public:
504  moValue();
505  moValue( const moValue &src);
506  moValue( const moText &strvalue, moValueType p_valuetype );
507  moValue( const moText &strvalue );
508  moValue( MOchar p_char );
509  moValue( MOint p_int );
510  moValue( MOlong p_long );
511  moValue( MOfloat p_float );
512  moValue( MOdouble p_double );
513 
514  moValue( const moText &strvalue, const moText &type );
515  moValue( const moText &strvalue, const moText &type, const moText &strvalue2, const moText &type2 );
516  moValue( const moText &strvalue, const moText &type, const moText &strvalue2, const moText &type2, const moText &strvalue3, const moText &type3 );
517  moValue( const moText &strvalue, const moText &type, const moText &strvalue2, const moText &type2, const moText &strvalue3, const moText &type3, const moText &strvalue4, const moText &type4 );
518 
519  void AddSubValue(const moText &strvalue, moValueType p_valuetype );
520 
521  void AddSubValue(const moText &strvalue, const moText &type );
522 
523  void AddSubValue(const moValueBase &valuebase);
524 
525  void RemoveSubValue( MOint p_indexsubvalue );
526 
527  void RemoveSubValues( bool leavefirstone = true );
528 
529  virtual ~moValue();
530 
531  moValue &operator = (const moValue &src);
532  moValueBase &operator [] ( MOint p_indexsubvalue ) {
533  if (p_indexsubvalue!=-1) {
534  return m_List[p_indexsubvalue];
535  } else {
536  return m_List[0];
537  }
538  }
539  moValueBase &GetSubValue( MOint p_indexsubvalue = 0 ) {
540  return m_List[p_indexsubvalue];
541  }
543  return m_List[GetSubValueCount() - 1];
544  }
546  return m_List.Count();
547  }
549  return *this;
550  }
551 
552  int Set( const moText& p_XmlText );
553  const moText& ToJSON();
554  const moText& ToXML();
555 
556  private:
557  moValueBases m_List;
558  moText m_FullJSON;
559  moText m_FullXML;
560 };
561 
562 
564 
565 #endif
566 
Valor de un Parámetro.
Definition: moValue.h:501
#define MOulong
Definition: moTypes.h:392
MOint m_ParamIndex
Definition: moValue.h:323
Tempo, beat, ritmo.
Definition: moTempo.h:44
MOdouble m_LastEval
Definition: moValue.h:282
moDataType
Definition: moValue.h:98
MOint m_Int
Definition: moValue.h:135
MOdouble m_Double
Definition: moValue.h:137
MOint m_ValueIndex
Definition: moValue.h:324
clase base para una fuente 3d o 2d
Definition: moFontManager.h:63
moValueBase & GetSubValue(MOint p_indexsubvalue=0)
Definition: moValue.h:539
moValue & Ref()
Definition: moValue.h:548
moDatas moDataMessage
Definition: moValue.h:149
moText m_Text
Definition: moValue.h:272
#define MOchar
Definition: moTypes.h:397
function x(bx)
Definition: jquery.js:30
moDeclareExportedDynamicArray(moData, moDatas)
MOchar m_Char
Definition: moValue.h:134
const moValueDefinition & GetValueDefinition() const
Devuelve una referencia a la definición del valor [ nombre de codigo, rango, tipo, índice ].
Definition: moValue.h:415
#define LIBMOLDEO_API
Definition: moTypes.h:180
#define MOfloat
Definition: moTypes.h:403
bool m_bFilteredParams
Definition: moValue.h:277
clase de para manejar textos
Definition: moText.h:75
#define MOlong
Definition: moTypes.h:391
moDataType m_DataType
Definition: moValue.h:270
Buffer de imágenes para video.
MOulong m_DataSize
Definition: moValue.h:273
#define MOint
Definition: moTypes.h:388
a max
Definition: jquery.js:72
MOfloat m_AlphaFilter
Definition: moValue.h:278
Clase Base para Objetos Moldeo ( moEffect, moIODevice, moResource, moConsole )
clase base para el manejo de una textura
Definition: moTexture.h:78
Clase base de sonido.
std::map< std::string, moData > moAttributes
Definition: moValue.h:290
moValueBase & GetLastSubValue()
Definition: moValue.h:542
moTextFilterParam m_pFilterParam
Definition: moValue.h:279
#define MOdouble
Definition: moTypes.h:404
moMatrix3 & operator=(const moMatrix3 &rkM)
#define MOlonglong
Definition: moTypes.h:393
MOfloat m_Float
Definition: moValue.h:138
MOlonglong m_Long
Definition: moValue.h:136
#define MOuint
Definition: moTypes.h:387
MOpointer m_Pointer
Definition: moValue.h:139
moData * m_pAlphaFilter
Definition: moValue.h:280
void SetValueDefinition(moValueDefinition &p_valuedefinition)
Fija la definición del valor [ nombre de codigo, rango, tipo, índice ].
Definition: moValue.h:405
MOuint GetSubValueCount()
Definition: moValue.h:545
bool m_bFilteredAlpha
Definition: moValue.h:276
moNumber m_Number
Definition: moValue.h:271
moMathFunction
#define MOpointer
Definition: moTypes.h:409
moValueType
Definition: moValue.h:300
const Real * operator[](int iRow) const