bugfix: include path + reindent
This commit is contained in:
parent
26dffce470
commit
d0ccff195f
1 changed files with 33 additions and 33 deletions
|
|
@ -5,42 +5,42 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "reflect/TypeDescr.hpp"
|
||||
#include "TypeDescr.hpp"
|
||||
#include <vector>
|
||||
|
||||
namespace xo {
|
||||
namespace reflect {
|
||||
/* represents a map :: TypeId -> Value */
|
||||
template<typename Value>
|
||||
class TypeDrivenMap {
|
||||
public:
|
||||
Value const * lookup(TypeId id) const { return this->lookup_slot(id); }
|
||||
namespace reflect {
|
||||
/* represents a map :: TypeId -> Value */
|
||||
template<typename Value>
|
||||
class TypeDrivenMap {
|
||||
public:
|
||||
Value const * lookup(TypeId id) const { return this->lookup_slot(id); }
|
||||
|
||||
Value * require(TypeId id) { return this->require_slot(id); }
|
||||
Value * require(TypeDescr td) { return this->require_slot(td->id()); }
|
||||
|
||||
private:
|
||||
Value const * lookup_slot(TypeId id) const {
|
||||
if (this->contents_v_.size() <= id.id())
|
||||
return nullptr;
|
||||
Value * require(TypeId id) { return this->require_slot(id); }
|
||||
Value * require(TypeDescr td) { return this->require_slot(td->id()); }
|
||||
|
||||
return &(this->contents_v_[id.id()]);
|
||||
} /*lookup_slot*/
|
||||
private:
|
||||
Value const * lookup_slot(TypeId id) const {
|
||||
if (this->contents_v_.size() <= id.id())
|
||||
return nullptr;
|
||||
|
||||
Value * require_slot(TypeId id) {
|
||||
if (this->contents_v_.size() <= id.id())
|
||||
this->contents_v_.resize(id.id() + 1);
|
||||
return &(this->contents_v_[id.id()]);
|
||||
} /*lookup_slot*/
|
||||
|
||||
return &(this->contents_v_[id.id()]);
|
||||
} /*require_slot*/
|
||||
Value * require_slot(TypeId id) {
|
||||
if (this->contents_v_.size() <= id.id())
|
||||
this->contents_v_.resize(id.id() + 1);
|
||||
|
||||
private:
|
||||
/* since TypeId/s are unique, compact sequence numbers,
|
||||
* can efficiently store mapping to Values using a vector indexed by TypeId
|
||||
*/
|
||||
std::vector<Value> contents_v_;
|
||||
}; /*TypeDrivenMap*/
|
||||
} /*namespace reflect*/
|
||||
return &(this->contents_v_[id.id()]);
|
||||
} /*require_slot*/
|
||||
|
||||
private:
|
||||
/* since TypeId/s are unique, compact sequence numbers,
|
||||
* can efficiently store mapping to Values using a vector indexed by TypeId
|
||||
*/
|
||||
std::vector<Value> contents_v_;
|
||||
}; /*TypeDrivenMap*/
|
||||
} /*namespace reflect*/
|
||||
} /*namespace xo*/
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue