-
Notifications
You must be signed in to change notification settings - Fork 30
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
Update Messages property of the DBC class to Dictionary #14
Comments
Sounds interesting. I din't use Dictionary in C# yet, so if you are willing to help I would be more than happy |
I guess this also somewhat ties into issue #15 making message a dictionary would help in solving this issue as well. |
@EFeru For the messages and the nodes you can just change Dbc properties to Dictionaries since the builder already uses a Dictionary to populate them. For the ValueTable lookup for a signal I've made a workaround in https://github.com/hakwes/DbcParser/blob/currentinternalrelease/DbcParserLib/DbcBuilder.cs#:~:text=%7D-,public%20void%20LinkTableValuesToSignal(uint%20messageId%2C%20string%20signalName%2C%20string,%7D,-private%20bool%20CheckExtID This fix also solves #13 . I attempted to put that in the ValueTableLineParser but it broke to many tests so i opted for the quickfix above. |
@hakwes Are you willing to support on converting to Dictionary? Especially the Value Tables would be really nice to have them as Dictionary. |
Sure, I'll have a go at it @EFeru |
Hi, Why I would not change Node and Message container type to
|
I fear the two things are unrelated A |
Hi @Adhara3 , thanks for your detailed answer. Is very good to have both advantages and disadvantages in our overview. |
So just to recap:
Cheers |
@Adhara3 I don't really understand your concerns about exposing the Message property as a Dictionary. The TryGet method is fine but I don't think you need to indexDbc class to implement that. |
@EFeru, @Adhara3 but i would also be interested in other usecases to see if there might be a better solution. |
I was just going through the code to check out how using a IReadonlydictionary for messages would change the code. (pretty much only the tests) |
…r for code cleanup; Add IsMultiplexed to signal
…old dbc class for backward compatibility
i know changed to code in a way that the dbc Class is the same as before but you can now convert to a immutable dbc class that works with the immutabel objects and dictionaries. The immutable classes support some more functions as they cant be changed, which solves #37 and is a part of solving #68. |
I think someone in the past asket to add messages but the usage requested was not clear since no At the moment the lib has been designed primarily with this exact scenario in mind. The Packer part has been kept separated because if is another kind of functionality, not directly related with the dbc in memory representation . So we could think of a method of some kind that takes the generic Dbc object and The overall design can be discussed, for now the lib is designed to work best on the scenario you described, I would not close the door to future developments to support other scenarios this is why I would not force stuff on the DBC class itself. Hope this clarifies the intent Cheers |
Hi @Adhara3, dbc.Messages.TryGetValue(myID, out Messsage myMessage) I think Messsage myMessage = dbc.Messages.Where(m => m.ID == myID); Regarding loading multiple dbc files and clash between IDs, please correct if I am wrong, I think they should be treated as different dbc objects |
I think the change to dictionary is kind of obvios here as the dictionary is also used internally. the way i did is that internally a dictionary is used and externaly this dictionary is readonly. The thing i changed two was the properties because you could easily get null ref exceptions there because only one of the properties was set at any given time (either string, enum, double....). I think this change could be discussed |
Sure it is, the point was that if a user requires fast access and he knows that no duplications are in place, then he could always call the available:
It's one line. As I stated above, the fact the we use a dictionary internally (i.e. for parsing) may have different reasons than the public API. Please keep the two concepts separated. Cheers |
I would like to see the Messages property of the DBC class to be set as a Dictionary to improve lookup.
Another option would be to add a Get method that would use an internal dictionary.
Another suggestions is to add the ValueTable as a dictionary as a complement to the string. That would simplify mapping values to descriptions.
The text was updated successfully, but these errors were encountered: