JNR
laPropertyList.h
1 /*
2 
3 Jump'n'Run Engine
4 http://www.atanaslaskov.com/jnr/
5 
6 BSD LICENSE
7 Copyright (c) 2007-2013, Atanas Laskov
8 All rights reserved.
9 
10 Redistribution and use in source and binary forms, with or without
11 modification, are permitted provided that the following conditions are met:
12 1. Redistributions of source code must retain the above copyright notice,
13 this list of conditions and the following disclaimer.
14 2. Redistributions in binary form must reproduce the above copyright notice,
15 this list of conditions and the following disclaimer in the documentation
16 and/or other materials provided with the distribution.
17 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
18 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20 DISCLAIMED. IN NO EVENT SHALL ATANAS LASKOV BE LIABLE FOR ANY
21 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 
28 */
29 #ifndef M_PROPERTY_LIST
30 #define M_PROPERTY_LIST
31 
33 
34 
35 class laPropertyList: public laLoadableObj
36 {
37 protected:
38 
39  // Name of the TS element
40  char _strName[32];
41 
42  M_BOOL _bReadName; // nested list tweak
43  friend class laTypedObject;
44 
45  laPropertyList* _pParent;
46 
47  // Map of components
48  //
49  // Implementation NOTE:
50  // Sotred in separate maps for each type, in order
51  // to improve retreival speed
52  //
53  // Implementation NOTE:
54  // Instead of locating components in run-time,
55  // dynamic objects should store a pointer to the components they need
56  // ( e.g. in the load() or create() functions )
57  //
58  std::map<std::string, M_BOOL> _mapBool;
59  std::map<std::string, int> _mapInt;
60  std::map<std::string, double> _mapDouble;
61  std::map<std::string, laColor> _mapColor;
62  std::map<std::string, laPoint3> _mapPoint;
63 
64  std::map<std::string, rpgAttack> _mapAttack;
65  //std::map<std::string, rpgTrap> _mapTrap;
66 
67  std::map<std::string, char*> _mapText;
68  std::map<std::string, class laAnimatedModel*> _mapModel;
69  std::map<std::string, class fxParticleSystem*> _mapFx;
70 
71  std::vector<class laAnimatedModel*> _vModel;
72  std::vector<class fxParticleSystem*> _vFx;
73 
74  std::map<std::string, class laPropertyList*> _mapChildren;
75 
76  void _read_components(laFileParser* fp, char* strEndTag);
77 
78 public:
79  laPropertyList(void);
80  virtual ~laPropertyList(void);
81 
82  void discard();
83 
84  // This method is part of the laLoadableObj interface
85  virtual void load(class laFileParser *fp);
86 
87  // Get TS element name
88  char* name() { return _strName; }
89 
90  // Components
91  //
92  M_BOOL getBool(std::string name);
93  int getInt(std::string name);
94  double getDouble(std::string name);
95  char* getText(std::string name);
96  laColor getColor(std::string name);
97  laPoint3 getPoint(std::string name);
98  rpgAttack attack(std::string name);
99  /*rpgTrap trap(std::string name);*/
100  laAnimatedModel* getModel(std::string name);
101  fxParticleSystem* getFx(std::string name);
102 
103  // Hierarchy tree
104  //
105  laPropertyList* getChild(std::string name);
106 
107  laPropertyList* getParent() { return _pParent; }
108 
109  laPropertyList* getTopmost();/* {
110  if(_pParent)
111  return _pParent->getTopmost();
112  return this;
113  }*/
114 
115  // Models and Fx components
116  //
117  laAnimatedModel* getModel(unsigned i);
118  unsigned getModelCnt() {return _vModel.size(); }
119 
120  fxParticleSystem* getFx(unsigned i);
121  unsigned getFxCnt() {return _vFx.size(); }
122 };
124 #endif
Animated 3D Model.
Interface for loadable objects.
Definition: laLoadableObj.h:43
Attack RPG Properties.
Definition: rpgAttack.h:55
File Parser.
Definition: laFileParser.h:41