28 ExportProfileManager::register_all_configs ()
30 list<TimespanNodePtr>::iterator tsl_it;
32 list<GraphNode *>::const_iterator cc_it;
33 for (cc_it = (*tsl_it)->get_children().begin(); cc_it != (*tsl_it)->get_children().end(); ++cc_it) {
34 list<GraphNode *>::const_iterator f_it;
35 for (f_it = (*cc_it)->get_children().begin(); f_it != (*cc_it)->get_children().end(); ++f_it) {
36 list<GraphNode *>::const_iterator fn_it;
37 for (fn_it = (*f_it)->get_children().begin(); fn_it != (*f_it)->get_children().end(); ++fn_it) {
41 if (!(ts_node = boost::dynamic_pointer_cast<TimespanNode> (*tsl_it))) {
42 throw ExportFailed (
X_(
"Programming error, Invalid pointer cast in ExportProfileManager"));
45 TimespanListPtr ts_list = ts_node->data()->timespans;
46 TimespanList::iterator ts_it;
47 for (ts_it = ts_list->begin(); ts_it != ts_list->end(); ++ts_it) {
49 TimespanPtr timespan = *ts_it;
52 if (!(cc_node = dynamic_cast<ChannelConfigNode *> (*cc_it))) {
53 throw ExportFailed (
X_(
"Programming error, Invalid pointer cast in ExportProfileManager"));
55 ChannelConfigPtr channel_config = cc_node->
data()->config;
58 if (!(f_node = dynamic_cast<FormatNode *> (*f_it))) {
59 throw ExportFailed (
X_(
"Programming error, Invalid pointer cast in ExportProfileManager"));
61 FormatPtr format = f_node->
data()->format;
64 if (!(fn_node = dynamic_cast<FilenameNode *> (*fn_it))) {
65 throw ExportFailed (
X_(
"Programming error, Invalid pointer cast in ExportProfileManager"));
67 FilenamePtr filename = fn_node->
data()->filename;
69 handler->add_export_config (timespan, channel_config, format, filename);
78 ExportProfileManager::create_empty_config ()
81 timespan->data()->timespans->push_back (handler->add_timespan());
87 if (!format_list.empty()) {
97 timespan->add_child (channel_config.
get(), 0);
98 channel_config->add_child (format.
get(), 0);
99 format->add_child (filename.
get(), 0);
109 uint32_t ExportProfileManager::GraphNode::id_counter = 0;
111 ExportProfileManager::GraphNode::GraphNode ()
116 ExportProfileManager::GraphNode::~GraphNode ()
118 while (!children.empty()) {
119 remove_child (children.front());
122 while (!parents.empty()) {
123 parents.front()->remove_child (
this);
128 ExportProfileManager::GraphNode::add_parent (
GraphNode * parent)
130 for (list<GraphNode *>::iterator it = parents.begin(); it != parents.end(); ++it) {
136 parents.push_back (parent);
140 ExportProfileManager::GraphNode::add_child (
GraphNode * child,
GraphNode * left_sibling)
142 for (list<GraphNode *>::iterator it = children.begin(); it != children.end(); ++it) {
151 children.push_back (child);
158 ExportProfileManager::GraphNode::is_ancestor_of (
GraphNode const * node)
const
160 for (list<GraphNode *>::const_iterator it = children.begin(); it != children.end(); ++it) {
170 ExportProfileManager::GraphNode::is_descendant_of (
GraphNode const * node)
const
172 for (list<GraphNode *>::const_iterator it = parents.begin(); it != parents.end(); ++it) {
184 if (_selected == value) {
return; }
187 SelectChanged (value);
191 ExportProfileManager::GraphNode::remove_parent (
GraphNode * parent)
193 for (list<GraphNode *>::iterator it = parents.begin(); it != parents.end(); ++it) {
202 ExportProfileManager::GraphNode::remove_child (
GraphNode * child)
204 for (list<GraphNode *>::iterator it = children.begin(); it != children.end(); ++it) {
218 if ((ts_node = dynamic_cast<TimespanNode *> (node))) {
224 if ((cc_node = dynamic_cast<ChannelConfigNode *> (node))) {
230 if ((f_node = dynamic_cast<FormatNode *> (node))) {
236 if ((fn_node = dynamic_cast<FilenameNode *> (node))) {
246 if ((ts_node = dynamic_cast<TimespanNode *> (node))) {
252 if ((cc_node = dynamic_cast<ChannelConfigNode *> (node))) {
258 if ((f_node = dynamic_cast<FormatNode *> (node))) {
264 if ((fn_node = dynamic_cast<FilenameNode *> (node))) {
274 list<TimespanNodePtr>::iterator tmp = it;
277 if ((*tmp)->get_children().empty()) {
283 list<ChannelConfigNodePtr>::iterator tmp = it;
286 if ((*tmp)->get_parents().empty()) {
292 list<FormatNodePtr>::iterator tmp = it;
295 if ((*tmp)->get_parents().empty()) {
301 list<FilenameNodePtr>::iterator tmp = it;
304 if ((*tmp)->get_parents().empty()) {
316 typename list<T>::iterator it;
317 for (it = the_list.begin(); it != the_list.end(); ++it) {
318 if (*it == position) {
319 the_list.insert (++it, element);
324 std::cerr <<
"invalid position given to ExportProfileManager::insert_after (aborting)" << std::endl;
333 typename list<T>::iterator it;
334 for (it = the_list.begin(); it != the_list.end(); ++it) {
335 if (*it == element) {
348 list<ExportProfileManager::GraphNode *>::const_iterator
351 if ((*beginning)->get_children().size() != 1) {
return beginning; }
354 list<GraphNode *>::const_iterator it = beginning;
355 while (it != the_list.end() && (*it)->get_children().size() == 1 && (*it)->get_children().front() == child) {
365 list<GraphNode *>
const & node_parents = old_node->
get_parents();
366 uint32_t split_index = (int) (node_parents.size() * position + 0.5);
367 split_index = std::max ((uint32_t) 1, std::min (split_index, node_parents.size() - 1));
369 list<GraphNode *>::const_iterator it = node_parents.begin();
370 for (uint32_t index = 1; it != node_parents.end(); ++index) {
371 if (index > split_index) {
372 list<GraphNode *>::const_iterator tmp = it++;
373 (*tmp)->add_child (new_node, old_node);
374 (*tmp)->remove_child (old_node);
403 node->get_parents().front()->add_child (new_config.
get(), node.
get());
405 if (node->get_children().size() == 1) {
406 new_config->add_child (node->first_child(), 0);
420 list<GraphNode *>
const & node_parents = node->get_parents();
421 if (node_parents.size() == 1) {
422 node_parents.front()->add_child (new_format.
get(), 0);
428 if (node->get_children().size() == 1) {
429 new_format->add_child (node->first_child(), 0);
443 list<GraphNode *>
const & node_parents = node->get_parents();
445 if (node_parents.size() == 1) {
446 node_parents.front()->add_child (new_filename.
get(), 0);
458 list<GraphNode *>
const & source_children = source->get_children();
464 if (!insertion_point) { insertion_point = source->last_child(); }
465 if (!(node_insertion_ptr = dynamic_cast<ChannelConfigNode *> (insertion_point))) {
466 throw ExportFailed (
X_(
"Programming error, Invalid pointer cast in ExportProfileManager"));
468 node_insertion_point = node_insertion_ptr->
self_ptr();
472 list<GraphNode *>::const_iterator common_children_begin = source_children.begin();
473 list<GraphNode *>::const_iterator common_children_end =
end_of_common_child_range (source_children, source_children.begin());
476 for (list<GraphNode *>::const_iterator it = source_children.begin(); it != source_children.end(); ++it) {
482 if (!(node = dynamic_cast<ChannelConfigNode *> (*it))) {
483 throw ExportFailed (
X_(
"Programming error, Invalid pointer cast in ExportProfileManager"));
491 node_insertion_point = new_node;
495 target->add_child (new_node.
get(), child_insertion_point);
496 child_insertion_point = new_node.
get();
498 if (one_grandchild) {
501 list<GraphNode *>::const_iterator past_end = common_children_end;
502 if (it == ++past_end) {
503 common_children_begin = it;
507 if (it == common_children_begin) {
508 GraphNode * grand_child_ins_pt = common_child;
509 if (!grand_child_ins_pt) {
510 grand_child_ins_pt = source->last_child()->last_child();
513 common_child = new_node->first_child();
515 new_node->add_child (common_child, 0);
524 list<GraphNode *>
const & source_children = source->get_children();
530 if (!insertion_point) { insertion_point = source->last_child(); }
531 if (!(node_insertion_ptr = dynamic_cast<FormatNode *> (insertion_point))) {
532 throw ExportFailed (
X_(
"Programming error, Invalid pointer cast in ExportProfileManager"));
534 node_insertion_point = node_insertion_ptr->
self_ptr();
538 list<GraphNode *>::const_iterator common_children_begin = source_children.begin();
539 list<GraphNode *>::const_iterator common_children_end =
end_of_common_child_range (source_children, source_children.begin());
542 for (list<GraphNode *>::const_iterator it = source_children.begin(); it != source_children.end(); ++it) {
548 if (!(node = dynamic_cast<FormatNode *> (*it))) {
549 throw ExportFailed (
X_(
"Programming error, Invalid pointer cast in ExportProfileManager"));
557 node_insertion_point = new_node;
561 target->add_child (new_node.
get(), child_insertion_point);
562 child_insertion_point = new_node.
get();
564 if (one_grandchild) {
567 list<GraphNode *>::const_iterator past_end = common_children_end;
568 if (it == ++past_end) {
569 common_children_begin = it;
573 if (it == common_children_begin) {
574 GraphNode * grand_child_ins_pt = common_child;
575 if (!grand_child_ins_pt) {
576 grand_child_ins_pt = source->get_parents().back()->last_child()->last_child()->last_child();
579 common_child = new_node->first_child();
581 new_node->add_child (common_child, 0);
594 if (!insertion_point) { insertion_point = source->last_child(); }
595 if (!(node_insertion_ptr = dynamic_cast<FilenameNode *> (insertion_point))) {
596 throw ExportFailed (
X_(
"Programming error, Invalid pointer cast in ExportProfileManager"));
598 node_insertion_point = node_insertion_ptr->
self_ptr();
600 for (list<GraphNode *>::const_iterator it = source->get_children().begin(); it != source->get_children().end(); ++it) {
606 if (!(node = dynamic_cast<FilenameNode *> (*it))) {
607 throw ExportFailed (
X_(
"Programming error, Invalid pointer cast in ExportProfileManager"));
615 node_insertion_point = new_node;
619 target->add_child (new_node.
get(), child_insertion_point);
620 child_insertion_point = new_node.
get();
627 TimespanStatePtr state = node->data();
628 TimespanStatePtr new_state (
new TimespanState ());
631 for (TimespanList::iterator it = state->timespans->begin(); it != state->timespans->end(); ++it) {
632 new_state->timespans->push_back (handler->add_timespan_copy (*it));
635 new_state->time_format = state->time_format;
636 new_state->marker_format = state->marker_format;
644 ChannelConfigStatePtr state = node->data();
645 ChannelConfigStatePtr new_state (
new ChannelConfigState (handler->add_channel_config_copy (state->config)));
654 FormatStatePtr state = node->data();
655 FormatStatePtr new_state (
new FormatState (handler->add_format_copy (state->format)));
664 FilenameStatePtr state = node->data();
665 FilenameStatePtr new_state (
new FilenameState (handler->add_filename_copy (state->filename)));
boost::shared_ptr< FormatNode > FormatNodePtr
A graph node that contains data.
boost::shared_ptr< TimespanNode > TimespanNodePtr
boost::shared_ptr< FilenameNode > FilenameNodePtr
void remove_filename(FilenameNodePtr node)
GraphNode * first_child() const
void split_timespan(TimespanNodePtr node, float position=0.5)
void remove_parent(GraphNode *parent)
void add_parent(GraphNode *parent)
list< FormatNodePtr > formats
boost::shared_ptr< ChannelConfigNode > ChannelConfigNodePtr
static void remove_by_element(list< T > &the_list, T const &element)
bool nodes_have_one_common_child(list< GraphNode * > const &the_list)
list< ChannelConfigNodePtr > channel_configs
FormatNodePtr duplicate_format_node(FormatNodePtr node)
list< GraphNode * > const & get_parents() const
list< TimespanNodePtr > timespans
list< GraphNode * >::const_iterator end_of_common_child_range(list< GraphNode * > const &the_list, list< GraphNode * >::const_iterator beginning)
list< GraphNode * > const & get_children() const
void remove_node(GraphNode *node)
void split_format(FormatNodePtr node, float position=0.5)
bool is_ancestor_of(GraphNode const *node) const
static void insert_after(list< T > &the_list, T const &position, T const &element)
void split_channel_config(ChannelConfigNodePtr node, float position=0.5)
void remove_timespan(TimespanNodePtr node)
FilenameNodePtr duplicate_filename_node(FilenameNodePtr node)
void duplicate_timespan_children(TimespanNodePtr source, TimespanNodePtr target, GraphNode *insertion_point=0)
list< FilenameNodePtr > filenames
MultiplicationGraph graph
void duplicate_format_children(FormatNodePtr source, FormatNodePtr target, GraphNode *insertion_point=0)
void remove_format(FormatNodePtr node)
void duplicate_channel_config_children(ChannelConfigNodePtr source, ChannelConfigNodePtr target, GraphNode *insertion_point=0)
LIBARDOUR_API PBD::PropertyDescriptor< framepos_t > position
LIBARDOUR_API PBD::PropertyDescriptor< bool > select
bool is_descendant_of(GraphNode const *node) const
static SelfPtr create(T *data)
void split_filename(FilenameNodePtr node, float position=0.5)
ChannelConfigNodePtr duplicate_channel_config_node(ChannelConfigNodePtr node)
PBD::Signal0< void > GraphChanged
A node in the hierarchical graph that represents a multiplicatable export item.
void split_node(GraphNode *node, float position)
void remove_channel_config(ChannelConfigNodePtr node)
void split_node_at_position(GraphNode *old_node, GraphNode *new_node, float position)
TimespanNodePtr duplicate_timespan_node(TimespanNodePtr node)