/// remote access to a mORMot server using mORMot units {{#uri}} // - retrieved from http://{{host}}/{{uri}} // at {{time}} using "{{templateName}}" template {{/uri}} {{^uri}} // - generated at {{time}} {{/uri}} unit {{fileName}}; { WARNING: This unit has been generated by a mORMot {{mORMotVersion}} server. Any manual modification of this file may be lost after regeneration. Synopse mORMot framework. Copyright (C) {{year}} Arnaud Bouchez Synopse Informatique - http://synopse.info This unit is released under a MPL/GPL/LGPL tri-license, and therefore may be freely included in any application. This unit would work on Delphi 6 and later, under Win32 and Win64 platforms, and with FPC 2.7/trunk revision, under Win32 and Linux32. } interface uses SynCommons, mORMot; {{! recursive partials used to write records type definition}} {{writerec}}{{nestedIdentation}} end;{{/nestedRecord}}{{#nestedSimpleArray}}array of {{typeDelphi}};{{/nestedSimpleArray}}{{#nestedRecordArray}}array of {{>writerec}}{{nestedIdentation}} end;{{/nestedRecordArray}} {{/fields}}{{/writerec}} {{textrec}} }{{/nestedRecord}}{{#nestedSimpleArray}}array of {{typeDelphi}}{{/nestedSimpleArray}}{{#nestedRecordArray}}[ {{>textrec}} ]{{/nestedRecordArray}} {{/fields}}{{/textrec}} {{#withEnumerates}} type // define some enumeration types, used below {{#enumerates}} {{name}} = ({{#values}}{{.}}{{^-last}}, {{/-last}}{{/values}}); {{/enumerates}} {{/withEnumerates}} {{#withSets}} type // define some set types, used below {{#sets}} {{name}} = set of({{#values}}{{.}}{{^-last}}, {{/-last}}{{/values}}); {{/sets}} {{/withSets}} {{#withRecords}} type // define some record types, used as properties below {{#records}} {{name}} = {{>writerec}} end; {{/records}} {{/withRecords}} {{#withArrays}} type // define some dynamic array types, used as properties below {{#arrays}} {{name}} = array of {{typeSource}}; {{/arrays}} {{/withArrays}} {{method}} {{/methods}} end; {{/soa.services}} /// return the database Model corresponding to this server function GetModel: TSQLModel; const /// the server port{{#uri}}, corresponding to http://{{host}}{{/uri}} SERVER_PORT = {{port}}; {{#soa.enabled}} /// define the interface-based services to be consummed by the client // - will define the following interfaces: {{#soa.services}} // ! I{{interfaceURI}} sic{{instanceCreationName}} {{GUID}} {{/soa.services}} procedure RegisterServices(Client: TSQLRestClientURI); {{/soa.enabled}} implementation {{#orm}} {{#hasRecords}} { {{className}} } class procedure {{className}}.InternalRegisterCustomProperties( Props: TSQLRecordProperties); begin {{#fields}} {{#isrecord}} Props.RegisterCustomPropertyFromRTTI(Self,TypeInfo({{typeDelphi}}), '{{name}}',@{{className}}(nil).f{{name}}); {{/isrecord}} {{/fields}} end; {{/hasRecords}} {{/orm}} function GetModel: TSQLModel; begin result := TSQLModel.Create([{{#orm}}{{className}}{{comma}}{{/orm}}],'{{root}}'); end; {{#soa.enabled}} procedure RegisterServices(Client: TSQLRestClientURI); begin {{#soa.services}} Client.ServiceRegister(TypeInfo(I{{interfaceURI}}),sic{{instanceCreationName}}); {{/soa.services}} end; {{/soa.enabled}} {{#withRecords}} const // text-based types definition for records and dynamic arrays {{#records}} __{{name}} = '{{>textrec}}'; {{/records}} initialization {{#enumerates}} TTextWriter.RegisterCustomJSONSerializerFromTextSimpleType( TypeInfo({{name}})); {{/enumerates}} {{#records}} TTextWriter.RegisterCustomJSONSerializerFromText( TypeInfo({{name}}),__{{name}}); {{/records}} {{/withRecords}} end.