Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Able to get the reference amount in the IHasPrimary key proeprty. #2056

Open
andy840119 opened this issue Jul 5, 2023 · 10 comments
Open

Able to get the reference amount in the IHasPrimary key proeprty. #2056

andy840119 opened this issue Jul 5, 2023 · 10 comments

Comments

@andy840119
Copy link
Member

andy840119 commented Jul 5, 2023

Found in the #2040 and #2057
We need to make sure that lyric should not be able to delete or split if the lyric is being referenced.

@andy840119 andy840119 changed the title Able to get the reference amount in the IHasPrimary key proeprty. Able to get the reference amount in the IHasPrimary key proeprty. Jul 5, 2023
@andy840119
Copy link
Member Author

andy840119 commented Jul 5, 2023

Maybe should make something like IHasReferenceElement interface and should implement the method like QueryAllReference(ElementId id) for able to get all the reference.

Those interface should be implemented in the:

  • KaraokeBeatmap
  • Stage and stage element.
  • Lyric
  • Note

Also note that QueryAllReference() in the KaraokeBeatmap() should query the hit-object also.

@andy840119
Copy link
Member Author

Not very sure but should worth to make a think:

  • How to find the element ids that does not have the reference item(the item might be deleted.)

@andy840119
Copy link
Member Author

Not very sure should save all referenced items inside the class that contains IHasPrimaryKey?
But might be hard to handle the event like undo or redo

@andy840119
Copy link
Member Author

Or maybe return a big dictionary that has all the reference ids.

@andy840119
Copy link
Member Author

andy840119 commented Jul 5, 2023

Or maybe this interface sounds like IHasFilterTerms in the o!f?

We collect list of ids and find the matched ids from the big Collection<KeyValuePair<ElementId, IHasReferenceElement>>

@andy840119
Copy link
Member Author

Maybe should use the attribute to mark all the properties that contains ElementId or IHasReferenceElement?
And write the algorithm together:
e.g.

var reference = ElementIdHelper.GetAllReference(beatmap);

or

var id = "abdcefd";
var reference = ElementIdHelper.GetAllReference(beatmap, id);

@andy840119
Copy link
Member Author

andy840119 commented Jul 6, 2023

另外有一個問題需要想一下
目前 lyric/note 已經有 working property 的機制,會不會讓這兩邊有重複的邏輯?

或是說能不能根據 id 和 type 去搜尋所有 matched 的 instance?

@andy840119
Copy link
Member Author

還有一個問題需要想一下
reference amount 應該要抓到正確的參考才對
e.g. lyric singer ids 如果 element id 是 lyric 的 ID,就會有抓錯的問題。

@andy840119
Copy link
Member Author

maybe reference 是參考哪個 property 內的哪個 property, like:

public class Lyric
{
  [ReferenceProperty(namepf(Lyric))]
  public ElementId? ReferenceLyricId {get;set;}
}

但可能會有一些問題:

  1. ReferenceLyricId 是從哪邊過來(e.g. beatmap.hitObjects) 的定義並不明確。如果未來多個地方都可以存放 lyric,會有參考問題
  2. 有點過度設計,會和 beatmap processor 內做的事情很像

如果換成另外一種想法,把 karaoke beatmap 當作是一個資料庫,這些東西是 table:

  • Singer (And Singer state)
  • Lyric
  • StageElement
  • ClassicLyricTimingPoint

那做的東西就會是單純的從 table 上面提取資料。
可能只需要定義哪些物件 table (e.g. StageCategory, ClassicStageInfo, SingerInfo, KaraokeBeatmap or IBeatmap)
並且可以從裡面拿到哪種型態的 row?

@andy840119
Copy link
Member Author

Not very sure but seems we can use source generator to deal with that?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant