Home Page   We Generate Your Software.
Products Services Company Technology Demo Contact Site Map Search
Please note: this document is currently under revision.
The information herein contained, while still valid, does not reflect the latest state of the described technology.
The Somusar/SoProTech[tm] Booklet Series
Volume III

"somusar/Sisendel: A Tutorial Introduction"

Printer friendly


Contents
1. Introduction
2. Sisendel Software Entities
3. Sisendel Basic Types
4. Sisendel User Types
5. Contents of an Entity File
6. Section CORE
7. Section DEFS
8. Section DB
9. Section LOGIC
9.1 Applying a Java[tm] mold
9.2 Applying a C++ mold
10. Section UI
11. Implicit Section DOC
12. Section ADJUST
13. Further Reading

Chapter 9 - Section LOGIC

The application logic section of an entity file allows to define how the data and function fields of a given entity should be grouped within the scope of the application-specific data processing layer of a software system.

Object classes, as well as transaction processing data structures and functions, should be defined within section LOGIC. The same considerations made for section DB apply here as well: field collection definitions are the only Sisendel rule applicable within section LOGIC, thus class or transaction definitions are to be expressed as Sisendel collections.

The following code examples have been generated by applying two simple LOGIC molds to sample entity employee, one mold to produce a Java[tm] class source file, and the other to produce a C++ class definition ".h" file.

9.1 - Applying a Java[tm] mold        top

Code Example 13 - From LOGIC.class and LOGIC.parent to "Employee.java"
The generated Java class is derived from collections LOGIC.class and LOGIC.parent. Collection LOGIC.class is used to generate Java source code as follows:
  • Collection members are mapped one-to-one to Java class members on lines 28-32; due to the lack of enums in Java, field position requires also the generation of lines 21-26;

  • Embedded or linked entities require the generation of import clauses (lines 15-16);

  • Lines 34-80 contain the generated get and set methods for the LOGIC.class members.

Collection LOGIC.parent, whose only member is person, is reflected on the import clause of line 14 and on the extends clause of line 18.
Source code - File "company/LOGIC/Employee.java"
    1      /*
    2       * This Java class generated by somusar/SoProMach[tm].
    3       */
    4      
    5      package com.somusar.entdemo.company;
    6      
    7      /**
    8       *   Class Employee:
    9       *
   10       *   An employee, some related information, and the 
   11       *   department s/he works in.
   12       */
   13      
   14      import com.somusar.entdemo.persons.Person;
   15      import com.somusar.entdemo.persons.PersonInfo;
   16      import com.somusar.entdemo.company.Department;
   17      
   18      public class Employee extends Person {
   19      
   20          // Map enum 'Position' onto an int with a set of values
   21          public final int PRESIDENT          = 0; // President
   22          public final int VICE_PRESIDENT     = 1; // Vice-president
   23          public final int MANAGER            = 2; // Manager
   24          public final int ADMIN              = 3; // Admin
   25          public final int SALES_REP          = 4; // Sales rep.
   26          public final int ENGINEER           = 5; // Engineer
   27      
   28          private int          emplId;             
   29          private PersonInfo   info;               
   30          private String       deptDeptId;         // relationship to Department
   31          private int          position;           // enum 'Position'
   32          private double       salary;             // range 0-1000000
   33          
   34          /*
   35           *   Get methods
   36           */
   37      
   38          public int getEmplId() {
   39              return emplId;
   40          }
   41      
   42          public PersonInfo getInfo() {
   43              return info;
   44          }
   45      
   46          public String getDeptDeptId() {
   47              return deptDeptId;
   48          }
   49      
   50          public int getPosition() {
   51              return position;
   52          }
   53      
   54          public double getSalary() {
   55              return salary;
   56          }
   57      
   58          /*
   59           *   Set methods
   60           */
   61      
   62          public void setEmplId( int emplId ) {
   63              this.emplId = emplId;
   64          }
   65      
   66          public void setInfo( PersonInfo info ) {
   67              this.info = info;
   68          }
   69      
   70          public void setDeptDeptId( String deptDeptId ) {
   71              this.deptDeptId = deptDeptId;
   72          }
   73      
   74          public void setPosition( int position ) {
   75              this.position = position;
   76          }
   77      
   78          public void setSalary( double salary ) {
   79              this.salary = salary;
   80          }
   81      
   82      }
	       

9.2 - Applying a C++ mold        top

Code Example 14 - From LOGIC.class and LOGIC.parent to "Employee.h"
Most of the notes about "Employee.java" also apply to "Employee.h": in fact, both Java and C++ are strongly based on the concepts of class and class inheritance, and entity files such as "employee.ef" are language-neutral with respect to such concepts, which are mapped to the Sisendel concept of collection.

The generated C++ class is derived from collections LOGIC.class and LOGIC.parent. Collection LOGIC.class is used to generate C++ source code as follows:

  • Collection members are mapped one-to-one to C++ class members on lines 47-51; the generated symbolic values for field position are shown on lines 36-43;

  • Embedded or linked entities require the generation of #include directives (lines 29-30);

  • Lines 55-101 contain the generated get and set methods for the LOGIC.class members.

Collection LOGIC.parent, whose only member is person, is reflected on the #include clause of line 28 and on the inheritance declaration of line 32.
Source code - File "company/LOGIC/Employee.h"
    1      #ifndef __Employee__
    2      #define __Employee__
    3      
    4      /*
    5       *   -----------------------------------------------------------------
    6       *   Class Employee
    7       *
    8       *   An employee, some related information, and the 
    9       *   department s/he works in.
   10       *   -----------------------------------------------------------------
   11       * 
   12       *   [This header generated by somusar/SoProMach[tm].]
   13       */
   14      
   15      
   16      
   17      #ifndef __dummy_classes__
   18      #   define __dummy_classes__
   19      
   20      /* Dummy declarations, just for compiling.  */
   21      class Collection { char s[100]; };
   22      class Object     { char s[100]; };
   23      
   24      #endif
   25      
   26      #include <String.h>
   27      
   28      #include "persons/Person.h"
   29      #include "persons/PersonInfo.h"
   30      #include "company/Department.h"
   31      
   32      class Employee : Person {
   33      
   34      public:
   35      
   36          enum enumPosition {
   37              PRESIDENT                  = 0,      // President
   38              VICE_PRESIDENT             = 1,      // Vice-president
   39              MANAGER                    = 2,      // Manager
   40              ADMIN                      = 3,      // Admin
   41              SALES_REP                  = 4,      // Sales rep.
   42              ENGINEER                   = 5       // Engineer
   43          };
   44      
   45      private:
   46      
   47          int                  emplId;             
   48          PersonInfo           info;               
   49          String               deptDeptId;         // relationship to Department
   50          enumPosition         position;           // enum 'Position'
   51          double               salary;             // range 0-1000000
   52      
   53      public:
   54      
   55          /*
   56           *   Get methods
   57           */
   58      
   59          int getEmplId() {
   60              return emplId;
   61          }
   62      
   63          PersonInfo getInfo() {
   64              return info;
   65          }
   66      
   67          String getDeptDeptId() {
   68              return deptDeptId;
   69          }
   70      
   71          enumPosition getPosition() {
   72              return position;
   73          }
   74      
   75          double getSalary() {
   76              return salary;
   77          }
   78      
   79          /*
   80           *   Set methods
   81           */
   82      
   83          void setEmplId( int emplId ) {
   84              this->emplId = emplId;
   85          }
   86      
   87          void setInfo( PersonInfo info ) {
   88              this->info = info;
   89          }
   90      
   91          void setDeptDeptId( String deptDeptId ) {
   92              this->deptDeptId = deptDeptId;
   93          }
   94      
   95          void setPosition( enumPosition position ) {
   96              this->position = position;
   97          }
   98      
   99          void setSalary( double salary ) {
  100              this->salary = salary;
  101          }
  102      
  103      };
  104      
  105      #endif /* __Employee__ */
	       

[Previous chapter]    [Next chapter]    [Back to top]

http:// www.somusar.com  / doc  / booklets  / sisendel_tut  - Powered by SoProMach
Copyright © 2003-2012 Somusar - Trademarks - Legal - Privacy - Webmaster