ModelBuilder

public class ModelBuilder

Class used by the code generator to create a model for your Store. Typical usage is:

let mBuilder = ModelBuilder()
let eBuilder = mBuilder.entityBuilder(for: myEntityInfo, id: 1, uid: 1001)
// ... set up the entity here
mBuilder.lastEntity(id: 1, uid: 1001)
mBuilder.lastIndex(id: 0, uid: 0) // This example model has no indexes.
let model = mBuilder.finish()
// create new Store using the model

See EntityBuilder documentation for details.

You usually don’t have to deal with this class.

  • Create a new ModelBuilder.

    Declaration

    Swift

    public init() throws
  • Create an entityBuilder for an entity with the given characteristics, local and unique ID, ready for specifying properties on. Do not use an EntityBuilder previously returned by this method after creating a new one using this method. This method implicitly ends definition of the previous entity builder.

    Declaration

    Swift

    public func entityBuilder<T: EntityInspectable>(for type: T.Type = T.self, id schemaEntityID: UInt32,
                                                    uid schemaEntityUID: UInt64)
        throws -> EntityBuilder<T>
  • Write the highest entity ID and UID used with into model. (This includes IDs for deleted entities)

    Declaration

    Swift

    public func lastEntity(id schemaEntityID: UInt32, uid schemaEntityUID: UInt64)
  • Register the highest index ID and UID used with the model. (This includes IDs for deleted indexes)

    Declaration

    Swift

    public func lastIndex(id schemaEntityID: UInt32, uid schemaEntityUID: UInt64)
  • Register the highest standalone relation ID and UID used with the model. (This includes IDs for deleted relations)

    Declaration

    Swift

    public func lastRelation(id relationID: UInt32, uid relationUid: UInt64)
  • Finish model creation and return an OBX_model suitable for passing to Store. Caller takes over ownership of returned pointer:

    Declaration

    Swift

    public func finish() -> OpaquePointer