bugfix: include path + reindent

This commit is contained in:
Roland Conybeare 2023-10-09 14:03:10 -04:00
commit d0ccff195f

View file

@ -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*/