Ophidian
 All Classes Namespaces Functions
property.h
1 /*
2  * Copyright 2016 Ophidian
3 Licensed to the Apache Software Foundation (ASF) under one
4 or more contributor license agreements. See the NOTICE file
5 distributed with this work for additional information
6 regarding copyright ownership. The ASF licenses this file
7 to you under the Apache License, Version 2.0 (the
8 "License"); you may not use this file except in compliance
9 with the License. You may obtain a copy of the License at
10 
11  http://www.apache.org/licenses/LICENSE-2.0
12 
13 Unless required by applicable law or agreed to in writing,
14 software distributed under the License is distributed on an
15 "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 KIND, either express or implied. See the License for the
17 specific language governing permissions and limitations
18 under the License.
19  */
20 
21 #ifndef OPHIDIAN_SRC_ENTITY_SYSTEM_PROPERTY_H
22 #define OPHIDIAN_SRC_ENTITY_SYSTEM_PROPERTY_H
23 
24 #include "entity.h"
25 
26 namespace ophidian{
27 namespace entity_system{
28 
30 
33 class property {
34  friend class attorney;
35 public:
36  property() {}
38  virtual ~property() { }
39 
40 private:
42 
46  virtual void destroy( entity_index e ) = 0;
47 
49 
53  virtual void create( ) = 0;
54 
56 
60  virtual void preallocate( std::size_t qnt ) = 0;
61 
62 };
63 
65 /*
66  * This class provides three static functions to access private methods from properties.
67  */
68 class attorney {
69 private:
70  inline static void destroy(property & p, entity_index e) {
71  return p.destroy(e);
72  }
73  inline static void create(property & p) {
74  return p.create();
75  }
76  inline static void preallocate(property & p, size_t qnt) {
77  return p.preallocate(qnt);
78  }
79  friend class entity_system;
80 };
81 
82 } /* namespace entity system */
83 } /* namespace ophidian */
84 
85 #endif //OPHIDIAN_SRC_ENTITY_SYSTEM_PROPERTY_H
Property class.
Definition: property.h:33
entity_system class.
Definition: entity_system.h:40
attorney class.
Definition: property.h:68
virtual ~property()
Virtual destructor.
Definition: property.h:38