Pol  Revision:4b29d2b
wornitems.h
Go to the documentation of this file.
1 #ifndef MOBILE_WORNITEMS_H
2 #define MOBILE_WORNITEMS_H
3 
4 #include <stddef.h>
5 
6 #include "../../clib/compilerspecifics.h"
7 #include "../containr.h"
8 
9 namespace Pol
10 {
11 namespace Bscript
12 {
13 class BObjectImp;
14 } // namespace Bscript
15 namespace Clib
16 {
17 class StreamWriter;
18 } // namespace Clib
19 namespace Core
20 {
21 class UObject;
22 } // namespace Core
23 namespace Items
24 {
25 class Item;
26 } // namespace Items
27 namespace Mobile
28 {
29 class Character;
30 } // namespace Mobile
31 } // namespace Pol
32 
33 namespace Pol
34 {
35 namespace Core
36 {
38 {
39  typedef UContainer base;
40 
41 public:
43  virtual ~WornItemsContainer(){};
44  virtual size_t estimatedSize() const POL_OVERRIDE;
45 
46  virtual Bscript::BObjectImp* make_ref() POL_OVERRIDE;
47  virtual Mobile::Character* get_chr_owner() POL_OVERRIDE;
49 
50  virtual UObject* owner() POL_OVERRIDE;
51  virtual const UObject* owner() const POL_OVERRIDE;
52  virtual UObject* self_as_owner() POL_OVERRIDE;
53  virtual const UObject* self_as_owner() const POL_OVERRIDE;
54 
55  virtual void for_each_item( void ( *f )( Items::Item* item, void* a ), void* arg ) POL_OVERRIDE;
56 
57  Items::Item* GetItemOnLayer( unsigned idx ) const;
58  void PutItemOnLayer( Item* item );
59  void RemoveItemFromLayer( Item* item );
60 
61  void print( Clib::StreamWriter& sw_pc, Clib::StreamWriter& sw_equip ) const;
62 };
63 
64 inline Items::Item* WornItemsContainer::GetItemOnLayer( unsigned idx ) const
65 {
66  if ( Items::valid_equip_layer( idx ) )
67  return ITEM_ELEM_PTR( contents_[idx] );
68 
69  return nullptr;
70 }
71 
73 {
74  return chr_owner;
75 }
76 }
77 }
78 
79 #endif
#define POL_OVERRIDE
virtual Mobile::Character * get_chr_owner() POL_OVERRIDE
Definition: wornitems.h:72
#define ITEM_ELEM_PTR(elem)
Definition: containr.h:39
bool valid_equip_layer(int layer)
Definition: item.h:383
Mobile::Character * chr_owner
Definition: wornitems.h:48
Definition: berror.cpp:12