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

configuration: Redo serialization #215

Open
2 tasks
Ondraceq opened this issue May 10, 2022 · 2 comments
Open
2 tasks

configuration: Redo serialization #215

Ondraceq opened this issue May 10, 2022 · 2 comments
Labels
refactor Code needs improvement

Comments

@Ondraceq
Copy link
Contributor

Ondraceq commented May 10, 2022

  • Add two phase serialization - to a tree structure (in c++) and in second step to json
  • Change module representation

New representation:

RofiWorld = { modules :: List<Module>, moduleJoints :: List<ModuleJoint>, spaceJoints :: List<SpaceJoint> }

Module = GenericModule | UniversalModule | PadModule | ... // { type :: string, id :: int, attributes :: Any?, ... }
GenericModule = { type :: "generic", id :: int, attributes :: Any?,
        connectors.count :: int, shoes.count :: int, bodies.count :: int,
        joints :: List<ComponentJoint> }
UniversalModule = { type :: "universal", id :: int, attributes :: Any?,
        ( alpha :: int, beta :: int, gamma :: int | joints.positions :: Array<Array<int, 1>, 3> ), joints.attributes :: Array<Any, 3>?,
        connectors.attributes :: Array<Any, 6>?, shoes.attributes :: Array<Any, 2>?, bodies.attributes :: Array<Any, 2>? }
PadModule = { type :: "pad", id :: int, width :: int, height :: int, attributes :: Any?,
        connectors.attributes :: Array<Any, 6>? }

ComponentJoint = { joint :: Joint, from :: ModuleComponent, to :: ModuleComponent }
SpaceJoint = { point :: Array<int, 3>, to :: Component, joint :: Joint }
ModuleJoint = { from :: Connector, to :: Connector, orientation :: Orientation }
Joint = RigidJoint | RotationJoint | ... // { type :: string, positions :: JointPositions, ... }
RigidJoint = { type :: "rigid", positions :: Array<int, 0>?, transformation :: Matrix? }
RotationJoint = { type :: "rotation", positions :: (Array<int, 1> | int), ... } // Specific, but I don't know

// Component in the current module
ModuleComponent = ModuleConnector | ModuleShoe | ModuleBody
ModuleConnector = { connector :: ConnectorId }
ModuleShoe = { shoe :: ShoeId }
ModuleBody = { body :: BodyId }
// Component with id of module it belongs to
Component = Connector | Shoe | Body
Connector = { id :: int, connector :: ConnectorId }
Shoe = { id :: int, shoe :: ShoeId }
Body = { id :: int, body :: BodyId }
// Component identifiers
ConnectorId = int | <module specific>
ShoeId = int | <module specific>
BodyId = int | <module specific>

Orientation = "North" | "East" | "South" | "West"
Matrix = Array<Array<int, 4>, 4> | "identity"
@Ondraceq
Copy link
Contributor Author

Also the callback should get all elems on path (e.g.) RofiWorld Module Connector index (all const).

And everything should be already built - this means that attributes are processed after parsing the configuration.

@Ondraceq Ondraceq added the refactor Code needs improvement label May 11, 2022
@Ondraceq
Copy link
Contributor Author

As discussed at #279
At least code parsing json should be separated to functions, but better solution would be to do the refactoring

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

No branches or pull requests

1 participant