|
|
|
@ -12,10 +12,10 @@ using namespace example_novel;
|
|
|
|
|
|
|
|
|
|
void FragmentExistsCheck::exists_check(std::shared_ptr<const ast_gen::GlobalElement> root,
|
|
|
|
|
std::shared_ptr<const ast_gen::ElementAccess> target) const {
|
|
|
|
|
if (target->element()->typeMark() == (int)example_novel::NovelNode::FragmentRefer) {
|
|
|
|
|
auto refer = std::dynamic_pointer_cast<const example_novel::FragmentRefers>(target->element());
|
|
|
|
|
if (target->element()->typeMark() == (int)NovelNode::FragmentRefer) {
|
|
|
|
|
auto refer = std::dynamic_pointer_cast<const FragmentRefers>(target->element());
|
|
|
|
|
auto signature = refer->storyRefer() + u8"&" + refer->fragmentRefer();
|
|
|
|
|
root->getNamedNodeBy((int)example_novel::NovelNode::FragmentDefine, signature);
|
|
|
|
|
root->getNamedNodeBy((int)NovelNode::FragmentDefine, signature);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (auto& xit : target->children()) {
|
|
|
|
@ -27,268 +27,199 @@ void FragmentExistsCheck::validCheck(std::shared_ptr<const ast_gen::ElementAcces
|
|
|
|
|
this->exists_check(std::dynamic_pointer_cast<const ast_gen::GlobalElement>(root->element()), root);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FragmentSortHelper::FragmentSortHelper(std::shared_ptr<const ast_gen::ElementAccess> node_bind, int story_sort) {
|
|
|
|
|
if (node_bind->element()->typeMark() == (int)example_novel::NovelNode::FragmentDefine) {
|
|
|
|
|
type_marks = Type::ELEMENT;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
type_marks = Type::REFER;
|
|
|
|
|
QString FragmentExistsCheck::name() const {
|
|
|
|
|
return u8"FragmentExistsCheck";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QList<std::shared_ptr<FragmentGraphHelper>> example_novel::FragmentGraphCheck::refers_cycle_check(
|
|
|
|
|
std::shared_ptr<FragmentGraphHelper> item, QList<std::shared_ptr<FragmentGraphHelper>> prevs) const {
|
|
|
|
|
if (prevs.contains(item)) {
|
|
|
|
|
return prevs << item;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
element_bind = node_bind;
|
|
|
|
|
next_attachment = nullptr;
|
|
|
|
|
this->story_sort = story_sort;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FragmentSortHelper::Type FragmentSortHelper::nodeType() const { return type_marks; }
|
|
|
|
|
|
|
|
|
|
std::shared_ptr<const ast_gen::ElementAccess> FragmentSortHelper::nodeBind() const { return element_bind; }
|
|
|
|
|
|
|
|
|
|
int FragmentSortHelper::storySort() const
|
|
|
|
|
{
|
|
|
|
|
return story_sort;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::shared_ptr<FragmentSortHelper> FragmentSortHelper::next() const {
|
|
|
|
|
return next_attachment;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void FragmentSortHelper::attachNext(std::shared_ptr<FragmentSortHelper> fragment) {
|
|
|
|
|
this->next_attachment = fragment;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void FragmentSortHelper::assignSibling(std::shared_ptr<FragmentSortHelper> other)
|
|
|
|
|
{
|
|
|
|
|
auto temp_list = this->siblings_store;
|
|
|
|
|
temp_list.append(other->siblings_store);
|
|
|
|
|
temp_list.append(other);
|
|
|
|
|
temp_list.append(shared_from_this());
|
|
|
|
|
|
|
|
|
|
QHash<QString, std::shared_ptr<FragmentSortHelper>> helpers;
|
|
|
|
|
for (auto& it : temp_list) {
|
|
|
|
|
helpers[it->element_bind->element()->signature()] = it;
|
|
|
|
|
auto next_list = item->nextList();
|
|
|
|
|
if (next_list.size()) {
|
|
|
|
|
prevs << item;
|
|
|
|
|
for (auto next : next_list) {
|
|
|
|
|
auto ref_link = refers_cycle_check(next, prevs);
|
|
|
|
|
if (ref_link.size())
|
|
|
|
|
return ref_link;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
temp_list = helpers.values();
|
|
|
|
|
for (auto& it : temp_list) {
|
|
|
|
|
auto vlist = temp_list;
|
|
|
|
|
vlist.removeAll(it);
|
|
|
|
|
return QList<std::shared_ptr<FragmentGraphHelper>>();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
it->siblings_store = vlist;
|
|
|
|
|
void FragmentGraphCheck::setElement(std::shared_ptr<FragmentGraphHelper> inst)
|
|
|
|
|
{
|
|
|
|
|
elements_store[inst->nodePeer()->signature()] = inst;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::shared_ptr<FragmentGraphHelper> FragmentGraphCheck::getElement(const QString& signature) const
|
|
|
|
|
{
|
|
|
|
|
return elements_store[signature];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QList<std::shared_ptr<FragmentGraphHelper>> example_novel::FragmentGraphCheck::getHangoutNodes() {
|
|
|
|
|
QList<std::shared_ptr<FragmentGraphHelper>> values;
|
|
|
|
|
|
|
|
|
|
for (auto node_item : elements_store) {
|
|
|
|
|
if (!node_item->inDegree())
|
|
|
|
|
values.append(node_item);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (auto inst : values) {
|
|
|
|
|
auto name = inst->nodePeer()->signature();
|
|
|
|
|
elements_store.remove(name);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return values;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QList<std::shared_ptr<FragmentSortHelper> > FragmentSortHelper::siblings() const
|
|
|
|
|
{
|
|
|
|
|
return siblings_store;
|
|
|
|
|
bool example_novel::FragmentGraphCheck::nodeDismantle(std::shared_ptr<FragmentGraphHelper> inst) {
|
|
|
|
|
bool flag = false;
|
|
|
|
|
|
|
|
|
|
for (auto item : inst->nextList()) {
|
|
|
|
|
item->inDegree()--;
|
|
|
|
|
flag = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return flag;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void FragmentOrdersCheck::elements_link_build(const QList<std::shared_ptr<StorySortHelper> >& stories)
|
|
|
|
|
void FragmentGraphCheck::validCheck(std::shared_ptr<const ast_gen::ElementAccess> root) const
|
|
|
|
|
{
|
|
|
|
|
QHash<QString, std::shared_ptr<StorySortHelper>> helper;
|
|
|
|
|
for (auto& i : stories)
|
|
|
|
|
helper[i->storyName()] = i;
|
|
|
|
|
std::function<QList<std::shared_ptr<const ast_gen::ElementAccess>>(std::shared_ptr<const ast_gen::ElementAccess>)> story_peak
|
|
|
|
|
= [&](std::shared_ptr<const ast_gen::ElementAccess> root)->QList<std::shared_ptr<const ast_gen::ElementAccess>> {
|
|
|
|
|
QList<std::shared_ptr<const ast_gen::ElementAccess>> return_temp;
|
|
|
|
|
|
|
|
|
|
auto auto_refer = [&](std::shared_ptr<StorySortHelper> story) {
|
|
|
|
|
auto fragment_head = story->fragmentSort();
|
|
|
|
|
while (fragment_head) {
|
|
|
|
|
switch (fragment_head->nodeType()) {
|
|
|
|
|
case FragmentSortHelper::Type::REFER:
|
|
|
|
|
{
|
|
|
|
|
auto access = fragment_head->nodeBind();
|
|
|
|
|
auto elm = std::dynamic_pointer_cast<const example_novel::FragmentRefers>(access->element());
|
|
|
|
|
if (!helper.contains(elm->storyRefer())) {
|
|
|
|
|
throw new lib_parse::CheckException(QString(u8"Parse[0x0001]故事线“%1”不存在!").arg(elm->storyRefer()));
|
|
|
|
|
}
|
|
|
|
|
auto story_target = helper[elm->storyRefer()];
|
|
|
|
|
auto fragm_target = story_target->fragment(elm->fragmentRefer());
|
|
|
|
|
if (!fragm_target) {
|
|
|
|
|
throw new lib_parse::CheckException(
|
|
|
|
|
QString(u8"Parse[0x0002]故事线“%1”的情节“%2”不存在!").arg(elm->storyRefer()).arg(elm->fragmentRefer()));
|
|
|
|
|
}
|
|
|
|
|
auto type_mark = (NovelNode)root->element()->typeMark();
|
|
|
|
|
if (type_mark == NovelNode::StoryDefine) {
|
|
|
|
|
return_temp << root;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fragment_head->assignSibling(fragm_target);
|
|
|
|
|
for (auto child : root->children()) {
|
|
|
|
|
return_temp.append(story_peak(child));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return return_temp;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
auto self = std::const_pointer_cast<FragmentGraphCheck>(this->shared_from_this());
|
|
|
|
|
|
|
|
|
|
// 获取所有故事线
|
|
|
|
|
auto all_story = story_peak(root);
|
|
|
|
|
// 注册图节点
|
|
|
|
|
for (auto story : all_story) {
|
|
|
|
|
auto fragment_items = story->children();
|
|
|
|
|
|
|
|
|
|
// 构建情节节点列表
|
|
|
|
|
for (auto frag_primitive : fragment_items) {
|
|
|
|
|
switch (frag_primitive->element()->typeMark()) {
|
|
|
|
|
case (int)NovelNode::FragmentDefine: {
|
|
|
|
|
auto target_node = std::dynamic_pointer_cast<const FragmentDefine>(frag_primitive->element());
|
|
|
|
|
auto finst = std::make_shared<FragmentGraphHelper>(target_node);
|
|
|
|
|
|
|
|
|
|
self->setElement(finst);
|
|
|
|
|
}break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fragment_head = fragment_head->next();
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
for (auto& vit : stories) {
|
|
|
|
|
auto_refer(vit);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template<class InputIt, class OutputIt, class Operate>
|
|
|
|
|
void cast(InputIt Begin, InputIt End, OutputIt Dst, Operate fn) {
|
|
|
|
|
while (Begin != End) {
|
|
|
|
|
*Dst++ = fn(*Begin++);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void FragmentOrdersCheck::sort_cycle_check(const QList<std::shared_ptr<FragmentSortHelper>>& tracks, std::shared_ptr<FragmentSortHelper> _current, int story_sort_source)
|
|
|
|
|
{
|
|
|
|
|
if (!_current || !_current->next())
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
auto target = _current->next();
|
|
|
|
|
|
|
|
|
|
if (tracks.contains(peaks_appoint_element(target))) {
|
|
|
|
|
QString error_cycle;
|
|
|
|
|
for (auto& it : tracks)
|
|
|
|
|
error_cycle += u8"->" + it->nodeBind()->element()->signature() + u8"\n";
|
|
|
|
|
error_cycle += u8"->" + target->nodeBind()->element()->signature() + u8"。";
|
|
|
|
|
|
|
|
|
|
throw new lib_parse::CheckException(u8"Parse[0x0003]排序异常:\n" + error_cycle);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
auto nlist = tracks;
|
|
|
|
|
nlist.append(peaks_appoint_element(target));
|
|
|
|
|
|
|
|
|
|
if (target->nodeType() == example_novel::FragmentSortHelper::Type::REFER) {
|
|
|
|
|
decltype (target->siblings()) sibling_forks;
|
|
|
|
|
|
|
|
|
|
auto siblings = target->siblings();
|
|
|
|
|
for (auto& vit : siblings) {
|
|
|
|
|
if (vit->storySort() <= story_sort_source)
|
|
|
|
|
sibling_forks << vit;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (auto& fork : sibling_forks) {
|
|
|
|
|
sort_cycle_check(nlist, fork, story_sort_source);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
sort_cycle_check(nlist, target, story_sort_source);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::shared_ptr<FragmentSortHelper> example_novel::FragmentOrdersCheck::peaks_appoint_element(std::shared_ptr<FragmentSortHelper> refer_n) const
|
|
|
|
|
{
|
|
|
|
|
if (refer_n->nodeType() == example_novel::FragmentSortHelper::Type::ELEMENT)
|
|
|
|
|
return refer_n;
|
|
|
|
|
|
|
|
|
|
auto sibs = refer_n->siblings();
|
|
|
|
|
for (auto ptr : sibs) {
|
|
|
|
|
if (ptr->nodeType() == example_novel::FragmentSortHelper::Type::ELEMENT)
|
|
|
|
|
return ptr;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return nullptr;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void FragmentOrdersCheck::validCheck(std::shared_ptr<const ast_gen::ElementAccess> root) const {
|
|
|
|
|
std::function<QList<std::shared_ptr<const ast_gen::ElementAccess>>(std::shared_ptr<const ast_gen::ElementAccess>)> peak_story =
|
|
|
|
|
[&](std::shared_ptr<const ast_gen::ElementAccess> pnode) -> QList<std::shared_ptr<const ast_gen::ElementAccess>> {
|
|
|
|
|
QList<std::shared_ptr<const ast_gen::ElementAccess>> listret;
|
|
|
|
|
|
|
|
|
|
if (pnode->element()->typeMark() == (int)example_novel::NovelNode::StoryDefine)
|
|
|
|
|
listret << pnode;
|
|
|
|
|
|
|
|
|
|
for (auto& vit : pnode->children())
|
|
|
|
|
listret.append(peak_story(vit));
|
|
|
|
|
|
|
|
|
|
return listret;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
auto stories = peak_story(root);
|
|
|
|
|
std::sort(std::begin(stories), std::end(stories),
|
|
|
|
|
[](std::shared_ptr<const ast_gen::ElementAccess> itema, std::shared_ptr<const ast_gen::ElementAccess> itemb) -> bool {
|
|
|
|
|
auto storya = std::dynamic_pointer_cast<const example_novel::StoryDefine>(itema->element());
|
|
|
|
|
auto storyb = std::dynamic_pointer_cast<const example_novel::StoryDefine>(itemb->element());
|
|
|
|
|
return storya->sort() < storyb->sort();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
for (auto& sit : stories) {
|
|
|
|
|
auto story_sort = std::make_shared<StorySortHelper>(sit);
|
|
|
|
|
const_cast<FragmentOrdersCheck*>(this)->stories_list << story_sort;
|
|
|
|
|
|
|
|
|
|
auto children = sit->children();
|
|
|
|
|
std::shared_ptr<FragmentSortHelper> temp_ptr = nullptr;
|
|
|
|
|
for (auto& nf : children) {
|
|
|
|
|
switch ((example_novel::NovelNode)nf->element()->typeMark()) {
|
|
|
|
|
case example_novel::NovelNode::FragmentDefine:
|
|
|
|
|
case example_novel::NovelNode::FragmentRefer: {
|
|
|
|
|
auto frag_sort = std::make_shared<FragmentSortHelper>(nf, story_sort->sortValue());
|
|
|
|
|
if (!temp_ptr) {
|
|
|
|
|
story_sort->attachFragmentSort(frag_sort);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
temp_ptr->attachNext(frag_sort);
|
|
|
|
|
}
|
|
|
|
|
temp_ptr = frag_sort;
|
|
|
|
|
} break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
default: break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 重复排序检查
|
|
|
|
|
int prev_sort = 0;
|
|
|
|
|
for (auto& s : stories_list) {
|
|
|
|
|
if (s->sortValue() < 1)
|
|
|
|
|
throw new lib_parse::CheckException(u8"Parse[0x0006]故事“%1”的排序<1。");
|
|
|
|
|
if (prev_sort >= s->sortValue()) {
|
|
|
|
|
auto idx = stories_list.indexOf(s);
|
|
|
|
|
auto prev = stories_list[idx - 1];
|
|
|
|
|
throw new lib_parse::CheckException(QString(u8"Parse[0x0007]故事“%1”与故事“%2”排序重复。").arg(s->storyName()).arg(prev->storyName()));
|
|
|
|
|
// 构建图连接
|
|
|
|
|
for (auto story : all_story) {
|
|
|
|
|
auto fragment_items = story->children();
|
|
|
|
|
|
|
|
|
|
// 过滤获取情节节点
|
|
|
|
|
for (auto idx = 0; idx < fragment_items.size(); idx++) {
|
|
|
|
|
auto fragment_inst = fragment_items[idx];
|
|
|
|
|
switch (fragment_inst->element()->typeMark())
|
|
|
|
|
{
|
|
|
|
|
case (int)NovelNode::FragmentDefine:
|
|
|
|
|
case (int)NovelNode::FragmentRefer:
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
fragment_items.removeAt(idx);
|
|
|
|
|
idx--;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
auto get_name = [](std::shared_ptr<const ast_gen::ElementAccess> node)->QString {
|
|
|
|
|
switch (node->element()->typeMark()) {
|
|
|
|
|
case (int)NovelNode::FragmentDefine: {
|
|
|
|
|
auto def_node = std::dynamic_pointer_cast<const example_novel::FragmentDefine>(node->element());
|
|
|
|
|
return def_node->signature();
|
|
|
|
|
}break;
|
|
|
|
|
case (int)NovelNode::FragmentRefer: {
|
|
|
|
|
auto ref_node = std::dynamic_pointer_cast<const example_novel::FragmentRefers>(node->element());
|
|
|
|
|
return ref_node->referSignature();
|
|
|
|
|
}break;
|
|
|
|
|
}
|
|
|
|
|
return QString();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// 构建完整图结构
|
|
|
|
|
for (auto fidx = 1; fidx < fragment_items.size(); fidx++) {
|
|
|
|
|
auto tail_name = get_name(fragment_items[fidx - 1]);
|
|
|
|
|
auto head_name = get_name(fragment_items[fidx]);
|
|
|
|
|
|
|
|
|
|
auto tail_helper = getElement(tail_name);
|
|
|
|
|
auto head_helper = getElement(head_name);
|
|
|
|
|
|
|
|
|
|
tail_helper->appendNext(head_helper);
|
|
|
|
|
head_helper->inDegree()++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const_cast<FragmentOrdersCheck*>(this)->elements_link_build(this->stories_list);
|
|
|
|
|
// 获取拓扑排序序列
|
|
|
|
|
auto values = self->getHangoutNodes();
|
|
|
|
|
for (auto idx = 0; idx < values.size(); ++idx) {
|
|
|
|
|
auto target = values[idx];
|
|
|
|
|
|
|
|
|
|
for (auto& s : this->stories_list) {
|
|
|
|
|
if(!s->fragmentSort())
|
|
|
|
|
continue;
|
|
|
|
|
self->nodeDismantle(target);
|
|
|
|
|
auto x_values = self->getHangoutNodes();
|
|
|
|
|
values.append(x_values);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QList<std::shared_ptr<FragmentSortHelper>> tracks;
|
|
|
|
|
tracks << peaks_appoint_element(s->fragmentSort());
|
|
|
|
|
const_cast<FragmentOrdersCheck*>(this)->sort_cycle_check(tracks, s->fragmentSort(), s->sortValue());
|
|
|
|
|
// 理论上不应该有残余
|
|
|
|
|
if (elements_store.size()) {
|
|
|
|
|
for (auto node : elements_store.values()) {
|
|
|
|
|
auto cycle_link = refers_cycle_check(node);
|
|
|
|
|
|
|
|
|
|
QString error_msg = u8"Parse[0x0006]情节图存在环形结构:\n";
|
|
|
|
|
for (auto n : cycle_link) {
|
|
|
|
|
error_msg += QString(u8"%1->").arg(n->nodePeer()->signature());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (cycle_link.size())
|
|
|
|
|
throw new lib_parse::CheckException(error_msg);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
StorySortHelper::StorySortHelper(std::shared_ptr<const ast_gen::ElementAccess> story_bind) {
|
|
|
|
|
this->story_bind = story_bind;
|
|
|
|
|
this->fragments_bind = nullptr;
|
|
|
|
|
QString example_novel::FragmentGraphCheck::name() const {
|
|
|
|
|
return u8"FragmentGraphCheck";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::shared_ptr<const example_novel::StoryDefine> StorySortHelper::storyElement() const {
|
|
|
|
|
return std::dynamic_pointer_cast<const example_novel::StoryDefine>(story_bind->element());
|
|
|
|
|
}
|
|
|
|
|
FragmentGraphHelper::FragmentGraphHelper(std::shared_ptr<const FragmentDefine> node) : node_peer(node) {}
|
|
|
|
|
|
|
|
|
|
QString StorySortHelper::storyName() const { return storyElement()->name(); }
|
|
|
|
|
|
|
|
|
|
int StorySortHelper::sortValue() const
|
|
|
|
|
std::shared_ptr<const FragmentDefine> FragmentGraphHelper::nodePeer() const
|
|
|
|
|
{
|
|
|
|
|
return storyElement()->sort();
|
|
|
|
|
return this->node_peer;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::shared_ptr<FragmentSortHelper> StorySortHelper::fragmentSort() const {
|
|
|
|
|
return this->fragments_bind;
|
|
|
|
|
void FragmentGraphHelper::appendNext(std::shared_ptr<FragmentGraphHelper> node) {
|
|
|
|
|
this->next_nodes.append(node);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void StorySortHelper::attachFragmentSort(std::shared_ptr<FragmentSortHelper> refer) {
|
|
|
|
|
this->fragments_bind = refer;
|
|
|
|
|
QList<std::shared_ptr<FragmentGraphHelper>> FragmentGraphHelper::nextList() const
|
|
|
|
|
{
|
|
|
|
|
return next_nodes;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::shared_ptr<FragmentSortHelper> StorySortHelper::fragment(const QString& name) const {
|
|
|
|
|
auto temp_ptr = fragments_bind;
|
|
|
|
|
|
|
|
|
|
do {
|
|
|
|
|
if (temp_ptr->nodeType() == FragmentSortHelper::Type::ELEMENT) {
|
|
|
|
|
auto node = std::dynamic_pointer_cast<const example_novel::FragmentDefine>(temp_ptr->nodeBind()->element());
|
|
|
|
|
if (node->name() == name)
|
|
|
|
|
return temp_ptr;
|
|
|
|
|
}
|
|
|
|
|
temp_ptr = temp_ptr->next();
|
|
|
|
|
} while (temp_ptr);
|
|
|
|
|
|
|
|
|
|
return nullptr;
|
|
|
|
|
uint& FragmentGraphHelper::inDegree()
|
|
|
|
|
{
|
|
|
|
|
return this->indegree;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|