READ_FRESH = 3,
WRITE = 4,
UPDATE = READ_OLD | WRITE,
- CHAINED_UPDATE = READ_FRESH | WRITE
+ CHAINED_UPDATE = READ_FRESH | WRITE,
+ DATA_MASK = 7,
+ RUN_BEFORE = 8,
+ RUN_AFTER = 16,
+ ORDER_MASK = 24
};
struct Dependency
template<typename T>
inline void System::declare_dependency(DependencyFlags flags)
{
- if(!std::is_base_of_v<Component, T>)
+ if((flags&DATA_MASK) && !std::is_base_of_v<Component, T>)
+ throw std::invalid_argument("System::declare_dependency");
+ if((flags&ORDER_MASK) && !std::is_base_of_v<System, T>)
throw std::invalid_argument("System::declare_dependency");
const Reflection::ClassBase &type = stage.get_reflector().get_or_create_class<T>();
if(i!=dependencies.end())
flags = static_cast<DependencyFlags>(flags|i->flags);
+ if((flags&RUN_BEFORE) && (flags&RUN_AFTER))
+ throw std::logic_error("conflicting order flags");
Dependency &dep = (i!=dependencies.end() ? *i : dependencies.emplace_back(type));
dep.flags = flags;