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.
moConfig.h
Ir a la documentación de este archivo.
1 /*******************************************************************************
2 
3  moConfig.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 #ifndef __MO_CONFIG_H__
32 #define __MO_CONFIG_H__
33 
34 #include "moTypes.h"
35 #include "moText.h"
36 #include "moParam.h"
37 #include "moArray.h"
38 #include "moPreConfig.h"
39 
40 #define MO_PARAM_NOT_SEL -1
41 #define MO_PARAM_NOT_FOUND -1
42 #define MO_CONFIGFILE_NOT_FOUND -1
43 #define MO_CONFIG_OK 0
44 #define MO_SELECTED -1
45 
47 
58 {
59  public:
60 
63 
65  virtual ~moConfigDefinition();
66 
68  moConfigDefinition( const moConfigDefinition& p_src );
69 
71  moConfigDefinition& operator =( const moConfigDefinition& p_src );
72 
74 
81  void Add( const moText& p_name, moParamType p_type, int p_index=-1, const moValue& p_defaultvalue = moValue("INVALID",MO_VALUE_UNDEFINED), const moText& p_OptionsStr = moText("") );
82 
84 
88  moParamDefinitions* GetParamDefinitions() {
89  return &m_ParamDefinitions;
90  }
91 
93 
97  moParamIndexes& ParamIndexes() { return m_ParamIndexes; }
98 
100 
106  void Set( moText p_objectname, moText p_objectclass ) {
107  m_ObjectName = p_objectname;
108  m_ObjectClass = p_objectclass;
109  }
110 
112 
117  return m_ObjectName;
118  }
119 
121 
126  return m_ObjectClass;
127  }
128 
130 
140  bool SetParamIndex( int defined_array_index, moParamIndex paramindex );
141  bool SetIndex( moText p_name, MOint p_index);
142 
144 
151  bool Exists( moText p_name );
152 
153  const moParamDefinition& GetParamDefinition( const moText& p_param_name );
154 
156  const moText& ToJSON();
157 
158  private:
159 
160  moParamDefinitions m_ParamDefinitions;
161 
162  moParamIndexes m_ParamIndexes;
163 
166 
168 };
169 
176 #define moDefineParamIndex(X,Y) if ( m_Config.GetConfigDefinition()!=NULL) {\
177  int pidx = (MOint)m_Config.GetParamIndex(Y);\
178  if (pidx>-1) {\
179  if (!m_Config.GetConfigDefinition()->SetParamIndex( (int)X, moParamIndex(pidx))) {\
180  MODebug2->Warning( "<"+m_Config.GetObjectClass()+">["+m_Config.GetObjectName()+"]::Init()_moDefineParamIndex > Config parameter \"" + moText(Y) + moText("\" warning. Bad indexation could cause errors."));\
181  }\
182  } else MODebug2->Error( m_Config.GetObjectClass()+": "+m_Config.GetObjectName()+ " parameter \"" + moText(Y) + moText("\" not found."));\
183  }
184 
194 {
195  public:
196 
198  moConfig();
199 
201  virtual ~moConfig();
202 
204 
210  void Set( moText p_objectname, moText p_objectclass ) {
211  m_ConfigDefinition.Set( p_objectname, p_objectclass);
212  }
213 
215 
220  return m_ConfigDefinition.GetObjectName();
221  }
222 
224 
229  return m_ConfigDefinition.GetObjectClass();
230  }
231 
233 
234  const moText& GetName() { return m_FileName; }
235 
237 
238  moParams& GetParams();
239 
240 
242 
243  MOboolean IsConfigLoaded();
244 
246 
247  int LoadConfig( moText p_filename );
248 
250 
257  void FixConfig();
258 
260 
265  void Indexation();
266 
268 
272  MOboolean CreateDefault( const moText &p_fullconfigfilename );
273 
275 
278  void UnloadConfig();
279 
281 
283  int SaveConfig( moText p_filename = moText(""));
284 
285 
287  void DeleteConfig();
288 
290 
291  moText GetFullText();
292 
294 
296  MOuint GetValuesCount( int p_paramindex );
297 
299 
302  moValue& GetValue( moText nameparam, int indexvalue = -1 );//el valor seleccionado del parametro
303 
305 
308  moValue& GetValue( int indexparam, int indexvalue = -1 );//el valor seleccionado del parametro
309 
310 
312 
314  MOint Int( moParamReference p_paramreference );
315  MOint Int( moText p_param_name );
316 
318 
320  MOdouble Double( moParamReference p_paramreference );
321  MOdouble Double( moText p_param_name );
322 
324 
326  moText Text( moParamReference p_paramreference );
327  moText Text( moText p_param_name );
328  moText Text( int p_param_index );
329 
331 
333  MOdouble Eval( moParamReference p_paramreference, double x, ... );
334  MOdouble Eval( moParamReference p_paramreference);
335  MOdouble Eval( moText p_param_name, double x, ... );
336  MOdouble Eval( moText p_param_name );
337 
338  moVector4d EvalColor( moParamReference p_paramreference );
339  moVector4d EvalColor( moParamReference p_paramreference, double x, ... );
340 
342 
344  GLint GetGLId( moParamReference p_paramreference, moMoldeoObject *p_object, moTempo *p_tempo, MOfloat p_fade, const moTextFilterParam &p_filterparam );
345  GLint GetGLId( moParamReference p_paramreference, MOfloat p_cycle, MOfloat p_fade, const moTextFilterParam &p_filterparam );
346  GLint GetGLId( moParamReference p_paramreference, moTempo *p_tempo, MOfloat p_fade, const moTextFilterParam &p_filterparam );
347  GLint GetGLId( moParamReference p_paramreference, MOuint p_i, MOfloat p_fade, const moTextFilterParam &p_filterparam );
348  GLint GetGLId( moParamReference p_paramreference, MOfloat p_fade, const moTextFilterParam &p_filterparam );
349 
350  GLint GetGLId( moParamReference p_paramreference, moMoldeoObject *p_object, moTempo *p_tempo );
351  GLint GetGLId( moParamReference p_paramreference, moMoldeoObject *p_object );
352  GLint GetGLId( moParamReference p_paramreference, MOfloat p_cycle);
353  GLint GetGLId( moParamReference p_paramreference, moTempo *p_tempo );
354  GLint GetGLId( moParamReference p_paramreference, MOuint p_i );
355  GLint GetGLId( moParamReference p_paramreference );
356 
357 
359  moMathFunction& Fun( moParamReference p_paramreference );
360  const moFont& Font( moParamReference p_paramreference );
361  const moTextureBuffer& TextureBuffer( moParamReference p_paramreference );
362  const moSceneNode& Model( moParamReference p_paramreference );
363  const moVector2d& Vector2d( moParamReference p_paramreference );
364  const moVector2i& Vector2i( moParamReference p_paramreference );
365  const moVector3d& Vector3d( moParamReference p_paramreference );
366  const moVector3i& Vector3i( moParamReference p_paramreference );
367  const moVector4d& Vector4d( moParamReference p_paramreference );
368  const moVector4i& Vector4i( moParamReference p_paramreference );
369  const moDataMessage& Message( moParamReference p_paramreference );
370  const moDataMessages& Messages( moParamReference p_paramreference );
371  moSound& Sound( moParamReference p_paramreference );
372  const moTexture& Texture( moParamReference p_paramreference );
373 
374 
376 
378  moParam& operator [] ( MOint p_paramindex ) {
379  return GetParam( p_paramindex );
380  }
381 
383 
385  moParam& operator [] ( moText p_paramname ) {
386  return GetParam( p_paramname );
387  }
388 
390 
392  moParam& operator [] ( moParamIndex p_paramindex ) {
393  return GetParam(p_paramindex.index );
394  }
395 
397 
399  moParam& operator [] ( moParamReference p_paramreference ) {
400  return GetParam( m_ConfigDefinition.ParamIndexes().Get(p_paramreference.reference) );
401  }
402 
404 
405  moParam& GetCurrentParam();
406 
408 
410  moParam& GetParam( MOint p_paramindex = -1 );
411 
413 
415  moParam& GetParam( moText p_paramname );
416 
418 
420  moParam& GetParam( moParamIndex p_paramindex ) {
421  return GetParam(p_paramindex.index );
422  }
423 
425 
427  moParam& GetParam( moParamReference p_paramreference ) {
428  return GetParam( m_ConfigDefinition.ParamIndexes().Get(p_paramreference.reference) );
429  }
430 
431 
433 
434  int GetParamsCount();
435 
437 
439  int GetCurrentValueIndex( MOint p_paramindex );
440 
442 
444  int GetParamIndex( moText p_paramname);
445 
447 
448  int GetCurrentParamIndex() const;
449 
451 
452  bool SetCurrentParamIndex( int);
453 
454  bool SetCurrentParam( const moText& p_param_name ) {
455  return SetCurrentParamIndex( GetParamIndex( p_param_name ) );
456  }
457 
459  void FirstParam();
460 
462  void NextParam();
463 
465  void PrevParam();
466 
468 
470  void SetCurrentValueIndex( int p_paramindex, int p_valueindex );
471 
473 
474  moValue& GetCurrentValue();
475 
477  bool FirstValue();
478 
480  bool NextValue();
481 
483  bool PreviousValue();
484 
486 
487  moConfigDefinition* GetConfigDefinition();
488 
489 
491 
492  MOint GetPreConfCount();
493 
495 
496  MOint GetCurrentPreConf();
497 
499 
500  void SetCurrentPreConf( MOint p_actual );
501 
503  void PreConfFirst();
504 
506  void PreConfNext();
507 
509  void PreConfPrev();
510 
511 
512 
513 
514 
516  void AddValue( int paramindex, moValue& p_value );
517 
519  void InsertValue( int paramindex, int valueindex, moValue& p_value );
520 
522  void SetValue( int paramindex, int valueindex, moValue& p_value );
523 
525  void DeleteValue( int paramindex, int valueindex );
526 
527 
529  const moPreConfig& GetPreconfig( int valueindex );
530 
532  void AddPreconfig( moPreconfigIndexes& p_preconfindexes );
533 
535  void AddPreconfig( int preconfig_index);
536 
538  void InsertPreconfig( int valueindex, moPreconfigIndexes& p_preconfindexes );
539 
541  void SetPreconfig( int valueindex, moPreconfigIndexes& p_preconfindexes );
542 
544  void DeletePreconfig( int valueindex );
545 
547  const moText& ToJSON();
548 
549  private:
550 
552  moParams m_Params;//los parametros del config
553  moPreConfigs m_PreConfigs;
555 
559 
560  int m_CurrentParam;// el indice que indica cual es el parametro actual.
563 
565  static moFont* m_pFont;
576  static moDataMessages* m_pMessages;
577  static moSound* m_pSound;
579 
580 
581  void CreateParam( moParamDefinition& p_ParamDef );
582 
584 };
585 
586 #endif
moText m_ObjectName
Definition: moConfig.h:164
moPreConfigs m_PreConfigs
Definition: moConfig.h:553
Valor de un Parámetro.
Definition: moValue.h:501
moText m_FileName
Definition: moConfig.h:558
static moMathFunction * m_pFun
Definition: moConfig.h:566
static moVector3d * m_pVector3d
Definition: moConfig.h:571
const moText & GetName()
Devuelve el nombre del archivo de configuraci�n.
Definition: moConfig.h:234
const moText & GetObjectClass()
Devuelve el nombre de la clase del objeto asociado a este config.
Definition: moConfig.h:125
const moText & GetObjectClass()
Devuelve el nombre de la clase del objeto asociado a este config.
Definition: moConfig.h:228
static moVector3i * m_pVector3i
Definition: moConfig.h:572
Tempo, beat, ritmo.
Definition: moTempo.h:44
static moDataMessages * m_pMessages
Definition: moConfig.h:576
clase base para una fuente 3d o 2d
Definition: moFontManager.h:63
moParamType
Definition: moParam.h:40
void Set(moText p_objectname, moText p_objectclass)
Fija el nombre y la clase del objeto a configurar.
Definition: moConfig.h:106
MOint m_PreconfActual
Definition: moConfig.h:562
static moTexture * m_pTexture
Definition: moConfig.h:578
moDatas moDataMessage
Definition: moValue.h:149
int m_CurrentParam
Definition: moConfig.h:560
#define MOboolean
Definition: moTypes.h:385
MOlong index
Definition: moParam.h:124
const moText & GetObjectName()
Devuelve el nombre del objeto asociado a este config.
Definition: moConfig.h:116
MOboolean m_ConfigLoaded
Definition: moConfig.h:551
Clase base abstracta de donde deben derivar los objetos [virtual pura].
Definition: moAbstract.h:191
moParam & GetParam(moParamIndex p_paramindex)
Devuelve el par�metro por estructura de �ndice (moParamIndex)
Definition: moConfig.h:420
moParamIndexes m_ParamIndexes
Definition: moConfig.h:162
#define LIBMOLDEO_API
Definition: moTypes.h:180
definici�n de todos los par�metros a encontrar o a crear dentro del moConfig
Definition: moConfig.h:57
#define MOfloat
Definition: moTypes.h:403
moText m_ObjectClass
Definition: moConfig.h:165
clase de para manejar textos
Definition: moText.h:75
moText m_FullJSON
Definition: moConfig.h:583
moParamIndexes & ParamIndexes()
Devuelve el puntero al arreglo de �ndices de los par�metros.
Definition: moConfig.h:97
moText0 moText
Definition: moText.h:291
static moVector4i * m_pVector4i
Definition: moConfig.h:574
#define MOint
Definition: moTypes.h:388
static moDataMessage * m_pMessage
Definition: moConfig.h:575
bool SetCurrentParam(const moText &p_param_name)
Definition: moConfig.h:454
Clase Base para Objetos Moldeo ( moEffect, moIODevice, moResource, moConsole )
static moTextureBuffer * m_pTextureBuffer
Definition: moConfig.h:567
static moVector4d * m_pVector4d
Definition: moConfig.h:573
clase base para el manejo de una textura
Definition: moTexture.h:78
void Set(moText p_objectname, moText p_objectclass)
Fija el nombre y la clase del objeto a configurar.
Definition: moConfig.h:210
Clase base de sonido.
MOint m_MajorVersion
Definition: moConfig.h:556
moParams m_Params
Definition: moConfig.h:552
MOint m_MinorVersion
Definition: moConfig.h:557
MOlong reference
Definition: moParam.h:98
moParam & GetParam(moParamReference p_paramreference)
Devuelve el par�metro por referencia de par�metro (moParamReference)
Definition: moConfig.h:427
#define MOdouble
Definition: moTypes.h:404
static moVector2d * m_pVector2d
Definition: moConfig.h:569
moConfigDefinition m_ConfigDefinition
Definition: moConfig.h:554
#define MOuint
Definition: moTypes.h:387
static moFont * m_pFont
solo para poder devolver una referencia
Definition: moConfig.h:565
const moText & GetObjectName()
Devuelve el nombre del objeto asociado a este config.
Definition: moConfig.h:219
static moSound * m_pSound
Definition: moConfig.h:577
moParamDefinitions * GetParamDefinitions()
Devuelve el puntero al arreglo de definciones de par�metros.
Definition: moConfig.h:88
static moVector2i * m_pVector2i
Definition: moConfig.h:570
moMathFunction
moParamDefinitions m_ParamDefinitions
Definition: moConfig.h:160
MOint m_PreconfParamNum
Definition: moConfig.h:561
static moSceneNode * m_pModel
Definition: moConfig.h:568
almacena la configuraci�n de los par�metros de un objeto en un archivo XML
Definition: moConfig.h:193