Ophidian
 All Classes Namespaces Functions
bins.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_BINS_H
22 #define ophidian_BINS_H
23 
24 #include <vector_property.h>
25 #include <entity_system.h>
26 #include "../geometry/geometry.h"
27 
28 namespace ophidian {
29  namespace density {
30 
31  class bins {
32  using point = geometry::point<double>;
33 
35 
38  entity_system::vector_property<double> m_movable_utilization;
39  entity_system::vector_property<double> m_fixed_utilization;
41 
42  public:
43 
44  bins(entity_system::entity_system & system) : m_system(system) {
45  m_system.register_property(&m_positions);
46  m_system.register_property(&m_dimensions);
47  m_system.register_property(&m_movable_utilization);
48  m_system.register_property(&m_fixed_utilization);
49  m_system.register_property(&m_free_space);
50  }
51 
52  virtual ~bins() { }
53 
54  point position(entity_system::entity bin) {
55  return m_positions[m_system.lookup(bin)];
56  }
57 
58  point dimension(entity_system::entity bin) {
59  return m_dimensions[m_system.lookup(bin)];
60  }
61 
62  double movable_utilization(entity_system::entity bin) {
63  return m_movable_utilization[m_system.lookup(bin)];
64  }
65 
66  double fixed_utilization(entity_system::entity bin) {
67  return m_fixed_utilization[m_system.lookup(bin)];
68  }
69 
70  double free_space(entity_system::entity bin) {
71  return m_free_space[m_system.lookup(bin)];
72  }
73 
74  std::pair< std::vector<point>::const_iterator, std::vector<point>::const_iterator > positions() const {
75  return std::make_pair(m_positions.begin(), m_positions.end());
76  }
77 
78  std::pair< std::vector<point>::const_iterator, std::vector<point>::const_iterator > dimensions() const {
79  return std::make_pair(m_dimensions.begin(), m_dimensions.end());
80  }
81 
82  std::pair< std::vector<double>::const_iterator, std::vector<double>::const_iterator > movable_utilizations() const {
83  return std::make_pair(m_movable_utilization.begin(), m_movable_utilization.end());
84  }
85 
86  std::pair< std::vector<double>::const_iterator, std::vector<double>::const_iterator > fixed_utilizations() const {
87  return std::make_pair(m_fixed_utilization.begin(), m_fixed_utilization.end());
88  }
89 
90  std::pair< std::vector<double>::const_iterator, std::vector<double>::const_iterator > free_spaces() const {
91  return std::make_pair(m_free_space.begin(), m_free_space.end());
92  }
93 
94  void position(entity_system::entity bin, point position);
95 
96  void dimension(entity_system::entity bin, point dimension);
97 
98  void movable_utilization(entity_system::entity bin, double movable_utilization);
99 
100  void fixed_utilization(entity_system::entity bin, double fixed_utilization);
101 
102  void free_space(entity_system::entity bin, double free_space);
103  };
104  }
105 }
106 
107 
108 #endif //ophidian_BINS_H
std::vector< T >::const_iterator begin() const
Begin iterator.
Definition: vector_property.h:137
std::vector< T >::const_iterator end() const
End iterator.
Definition: vector_property.h:146
entity_system class.
Definition: entity_system.h:40
Definition: bins.h:31
entity_index lookup(entity e) const
Gets the index of an entity.
Definition: entity_system.h:149
void register_property(property *property)
Registers property.
Definition: entity_system.cpp:61