void Sequencer::Loader::segment(float start, float end)
{
- SegmentLoader ldr(obj, start, end);
+ SegmentLoader ldr(obj, start, end, demo);
load_sub_with(ldr);
}
demo(d)
{
for(const auto &t: obj.action_types)
- add(t.first, t.second->get_loader_func());
+ add(t.first, t.second->get_def_loader_func());
}
void Sequencer::ActionDefLoader::finished()
}
-Sequencer::SegmentLoader::SegmentLoader(Sequencer &s, float b, float e):
+Sequencer::SegmentLoader::SegmentLoader(Sequencer &s, float b, float e, Demo &d):
ObjectLoader<Sequencer>(s),
start_beat(b),
- end_beat(e)
+ end_beat(e),
+ demo(d)
{
add("apply", &SegmentLoader::apply);
+ for(const auto &t: obj.action_types)
+ add(t.first, t.second->get_loader_func());
}
void Sequencer::SegmentLoader::apply(const string &n)
private:
class ActionDefLoader;
+ class SegmentLoader;
class RegisteredAction
{
public:
- typedef void (ActionDefLoader::*LoaderFunc)();
+ typedef void (ActionDefLoader::*DefLoaderFunc)();
+ typedef void (SegmentLoader::*LoaderFunc)();
virtual ~RegisteredAction() { }
+ virtual DefLoaderFunc get_def_loader_func() const = 0;
virtual LoaderFunc get_loader_func() const = 0;
};
class RegisteredActionType: public RegisteredAction
{
public:
+ virtual DefLoaderFunc get_def_loader_func() const;
virtual LoaderFunc get_loader_func() const;
};
private:
float start_beat;
float end_beat;
+ Demo &demo;
public:
- SegmentLoader(Sequencer &, float, float);
+ SegmentLoader(Sequencer &, float, float, Demo &);
private:
+ template<typename T>
+ void action();
+
void apply(const std::string &);
+
+ template<typename T>
+ friend class RegisteredActionType;
};
public:
private:
std::map<std::string, RegisteredAction *> action_types;
std::map<std::string, Action *> named_actions;
+ std::vector<Action *> anonymous_actions;
Msp::Time::TimeDelta secs_per_beat;
std::vector<Action *> static_actions;
}
template<typename T>
-Sequencer::RegisteredAction::LoaderFunc Sequencer::RegisteredActionType<T>::get_loader_func() const
+Sequencer::RegisteredAction::DefLoaderFunc Sequencer::RegisteredActionType<T>::get_def_loader_func() const
{
return &ActionDefLoader::action_def<T>;
}
+template<typename T>
+Sequencer::RegisteredAction::LoaderFunc Sequencer::RegisteredActionType<T>::get_loader_func() const
+{
+ return &SegmentLoader::action<T>;
+}
+
template<typename T>
void Sequencer::ActionDefLoader::action_def()
{
action = act;
}
+template<typename T>
+void Sequencer::SegmentLoader::action()
+{
+ Msp::RefPtr<T> act = new T;
+ load_sub(*act, demo);
+ obj.add_action(*act, start_beat, end_beat);
+ obj.anonymous_actions.push_back(act.release());
+}
+
#endif