// BlockyFroggy
// Created by John Ryland on 17/3/19
// Copyright © 2019 John Ryland. All rights reserved.
#pragma once
#ifndef Factory_h
#define Factory_h
template <typename T>
struct GenericFactoryItem
{
GenericFactoryItem(const char* a_name, T a_value)
: m_name(a_name), m_value(a_value), m_next(getFactoryHead())
{
getFactoryHead(this);
}
const char* m_name;
T m_value;
const GenericFactoryItem<T>* m_next;
static const GenericFactoryItem<T>* getFactoryHead(const GenericFactoryItem<T>* newValue = nullptr);
};
// It shouldn't matter, but for XCode this needed to not be inline in the definition above
template <typename T>
const GenericFactoryItem<T>* GenericFactoryItem<T>::getFactoryHead(const GenericFactoryItem<T>* newValue)
{
static const GenericFactoryItem<T>* s_factoryHead = nullptr;
if (newValue != nullptr)
s_factoryHead = newValue;
return s_factoryHead;
}
#endif /* Factory_h */