--********************************************************************************** -- This template represents the basic procedure needed to automatically generate -- the abstract domain package specifications. All fragments in uppercase type -- are replaced by application specific variables, types, etc. as noted in -- comments near the fragment. All lower case fragments are constant within -- the actual procedure and can be used directly as shown here. A version -- of this template without explanatory comments is supplied at the -- end of this file. --********************************************************************************** -- STEP 1 ************************************************************************** with abstract_domain_generator; -- the package which contains all domain generator generics to instantiate. with generator_support; use generator_support; -- the package which contains all constants, type names, etc. -- STEP 2 ************************************************************************** procedure PROG is -- can name procedure any valid Ada variable name, but must be used -- consistently throughout this procdure. -- STEP 3 ************************************************************************** -- The following type declaration represents all valid domain package names -- (i.e. the name of a packages that contains a group of domains) to be -- generated. These names can be any valid Ada variable names but must -- be used constistently throughout the procedure. type PACK_NAMES is (ALL VALID DOMAIN PACKAGE NAMES SEPARATED BY COMMAS HERE..EX -> suppliers_def_pkg, parts_def_pkg); -- Note the consistent use of type name PACK_NAMES in subsequent packages. -- This type can be named any valid Ada type name. -- STEP 4 ************************************************************************** -- Instantiate the outermost generic package, Abstract_Domain_Generator, -- with the above declared valid domain package names. From now on, only -- these package names will be recognized during elaboration of -- subsequent generic packages. package DOM_PACKS is new abstract_domain_generator (PACK_NAMES); -- Note the consistent use of package name DOM_PACKS in subsequent packages. -- This package can be named any valid Ada package name. -- STEP 5 *********************************************************************** -- Perform steps 5-8 for each package name declared above. -- For example, once for "suppliers_def_package" and once again for -- "parts_def_pkg. These steps instantiate the second level generic -- package, Generate_Domain_Package, with names of all domains belonging -- to this package and the name (from the list of valid domain package -- names) of this package. Note that from now on, only these domain -- names and this specific domain package name will be recognized during -- elaboration subsequent generic packages. -- Important note: Both package names and domain names can only be used -- once. begin declare type DOMS is (ALL VALID DOMAIN NAMES SEPARATED BY COMMAS HERE..EX-> sno, sname, city); -- Note the consistent use of type name DOMS in subsequent packages. -- This type can be named any valid Ada type name. -- STEP 6 *********************************************************************** package DOMAIN_1 is new DOM_PACKS.generate_domain_package (A VALID PACKAGE NAME..EX -> suppliers_def_pkg , DOMS); -- Note the consistent use of package name DOMAIN_1 in subsequent packages. -- This package can be named any valid Ada package name. -- STEP 7 ********************************************************************** -- Perform this step once for each domain declared above. -- First, instantiate a third level generic for each specific -- domain declared for this domain package. Which generic instantiated -- with what parameters is determined by the domain sql type. See -- generic package Abstract_Domain_Generator specification for -- descriptions. SQL types are char, int, smallint, double_precision, -- enumeration, real, decimal. There are six kinds of generics -- in this package: -- 1) Generate_Int_Domain -- Used to define char, int and smallint domain types. -- 2) Generate_Subint_Domain -- Used to define int and smallint subtypes -- based on a previously defined domain of the same type. -- Note that subtypes of type char are not allowed. -- 3) Generate_Flt_Domain -- Used to define real, double_precision and decimal domain types. -- 4) Generate_Subflt_Domain -- Used to define real, double_precison and decimal subtypes -- based on a previously defined domain of the same type. -- 5) Generate_Enum_Domain -- Used for enumeration domain types. -- 6) Generate_Subenum_Domain -- Used for enumeration subtypes based on a -- previously defined enumeration domain. -- Important note: although domains can be defined (regardless of type) -- in any order, subtypes can only be defined after the domain on -- which it is based has been defined. -- ******** To define a char, int or smallint domain -> package FIRST is new DOMAIN_1.generate_int_domain (DOMAIN_NAME, DOMAIN_TYPE, NULL_INDICATOR, RANGE_STAR, RANGE_STOP..EX -> See descriptions and example below); -- Package FIRST can be named any valid Ada package name. -- Parameter Descritions -- DOMAIN_NAME The name of the domain..EX -> pno -- DOMAIN_TYPE The SQL type..EX -> int -- NULL_INDICATOR (See note below) Always either: -- 1) "null_and_not_null" for both null bearing -- and non-null bearing types -- 2) "contains_null" for null bearing type -- 3) "not_null" for a non-null bearing type -- RANGE_START The number, always of type integer, -- representing range start..EX -> 1 -- RANGE_STOP The number, always of type integer, -- representing range stop..EX -> 100 -- Example of package FIRST -> -- package first is new domain_1.generate_int_domain -- (pno, int, not_null, 1, 100); -- Note: for NULL_INDICATOR in the case of int or smallint type domains -> -- using the "contains_null" indicator for numeric domains will -- result in the inability to use the Ada assign procedure with -- variables of this domain type in subsequent applications. -- For null bearing, numeric domain types, use "null_and_not_null" -- if the assign procedure will be needed. -- ******** To define a int or smallint subtype based on a domain -> package SECOND is new DOMAIN_1.generate_subint_domain (DOMAIN_NAME, DOMAIN_BASED_ON, DOMAIN_TYPE, NULL_INDICATOR, RANGE_START, RANGE_STOP)..EX -> See descriptions and example below); -- Package SECOND can be named any valid Ada package name. -- Important note: domains of sql type "char" cannot have subtypes -- The PARAMETER LIST is -- DOMAIN_NAME The name of the subtype..EX -> pno_over_50 -- DOMAIN_BASED_ON The name of the domain on which this subtype -- is based..EX -> pno -- DOMAIN_TYPE The SQL type..EX -> int -- NULL_INDICATOR (See note below) Always either: -- 1) "null_and_not_null" for both null bearing -- and non-null bearing subtypes -- 2) "contains_null" for null bearing subtype -- 3) "not_null" for a non-null bearing subtype -- RANGE_START The number, always of type integer, -- representing range start..EX -> 51 -- RANGE_STOP The number, always of type integer, -- representing range stop..EX -> 100 -- Example of package SECOND -> -- package second is new domain_1.generate_subint_domain -- (pno_over_50, pno, int, not_null, 51, 100); -- Note: for NULL_INDICATOR -> -- using the "contains_null" indicator for numeric subtypes will -- result in the inability to use the Ada assign procedure with -- variables of this subtype in subsequent applications. -- For null bearing, numeric subtypes, use "null_and_not_null" -- if the assign procedure will be needed. -- ******** To define a real, double_precision or decimal domain -> package THIRD is new DOMAIN_1.generate_flt_domain (DOMAIN_NAME, DOMAIN_TYPE, NULL_INDICATOR, RANGE_START, RANGE_STOP)..EX -> See descriptions and example below); -- Package THIRD can be named any valid Ada package name. -- The PARAMETER LIST is -- DOMAIN_NAME The name of the domain..EX -> price -- DOMAIN_TYPE The SQL type..EX -> decimal -- NULL_INDICATOR (See note below) Always either: -- 1) "null_and_not_null" for both null bearing -- and non-null bearing types -- 2) "contains_null" for null bearing type -- 3) "not_null" for a non-null bearing type -- RANGE_START The number, always of type float, -- representing range start..EX -> 0.00. -- RANGE_STOP The number, always of type float, -- representing range stop..EX -> 1000.00 -- Example of package THIRD -> -- package third is new domain_1.generate_flt_domain -- (price, decimal, not_null, 0.00, 1000.0); -- Note: for NULL_INDICATOR -> -- using the "contains_null" indicator for numeric domains will -- result in the inability to use the Ada assign procedure with -- variables of this domain type in subsequent applications. -- For null bearing, numeric domain types, use "null_and_not_null" -- if the assign procedure will be needed. -- ******** To define a real, double_precision or decimal subtype based on a domain -> package FOURTH is new DOMAIN_1.generate_subflt_domain (DOMAIN_NAME, DOMAIN_BASED_ON, DOMAIN_TYPE, NULL_INDICATOR, RANGE_START, RANGE_STOP..EX -> See descriptions and example below); -- Package FOURTH can be named any valid Ada package name. -- The PARAMETER LIST is -- DOMAIN_NAME The name of the subtype..EX -> mid_price -- DOMAIN_BASED_ON The name of the domain on which this subtype -- is based..EX -> price -- DOMAIN_TYPE The SQL type..EX -> decimal -- NULL_INDICATOR (See note below) Always either: -- 1) "null_and_not_null" for both null bearing -- and non-null bearing subtypes -- 2) "contains_null" for null bearing subtype -- 3) "not_null" for a non-null bearing subtype -- RANGE_START The number, always of type float, -- representing range start..EX -> 299.50 -- RANGE_STOP The number, always of type float, -- representing range stop..EX -> 699.50 -- Example of package FOURTH -> -- package fourth is new domain_1.generate_subflt_domain -- (mid_price, price, decimal, not_null, 299.50, 699.50); -- Note: for NULL_INDICATOR -> -- using the "contains_null" indicator for numeric subtypes will -- result in the inability to use the Ada assign procedure with -- variables of this subtype in subsequent applications. -- For null bearing, numeric subtypes, use "null_and_not_null" -- if the assign procedure will be needed. -- ******** To define an enumeration domain -> type VALS is (LIST OF VALUES HERE..EX -> red ,white, blue); -- Note the consistent use of type name VALS in subsequent packages. -- This type can be named any valid Ada type name. package FIFTH is new DOMAIN_1.generate_enum_domain (VALS, DOMAIN_NAME, DOMAIN_TYPE, NULL_INDICATOR..EX -> See description and example below); -- Package FIFTH can be named any valid Ada package name. -- The PARAMETER LIST is -- VALS Always "VALS" -- DOMAIN_NAME The name of the domain..EX -> colors -- DOMAIN_TYPE Always "enumeration" -- NULL_INDICATOR Always either: -- 1) "null_and_not_null" for both null bearing -- and non-null bearing types -- 2) "contains_null" for null bearing type -- 3) "not_null" for a non-null bearing type -- Example of package fifth -> -- type color_values is (red, white, blue); -- package fifth is new domain_1.generate_enum_domain -- (color_values, colors, enumeration, null_and_not_null); -- ******** To define an enumeration subtype -> package SIXTH is new DOMAIN_1.generate_subenum_domain (DOMAIN_NAME, DOMAIN_BASED_ON, DOMAIN_TYPE, NULL_INDICATOR, RANGE_START, RANGE_STOP..EX -> See description and example below); -- Package SIXTH can be named any valid Ada package name. -- The PARAMETER LIST is -- DOMAIN_NAME The name of the subtype..EX -> colors_not_red -- DOMAIN_BASED_ON The name of the domain on which this subtype -- is based..EX -> colors -- DOMAIN_TYPE Always "enumeration" -- NULL_INDICATOR Always either: -- 1) "null_and_not_null" for both null bearing -- and non-null bearing subtypes -- 2) "contains_null" for null bearing subtype -- 3) "not_null" for a non-null bearing subtype -- RANGE_START The string representing the enumerated vlaue that is -- range start in quotes..EX -> "white" -- RANGE_STOP The string representing the enumerated value that is -- range stop in quotes..EX -> "blue" -- Example of package SIXTH -> -- package sixth is new domain_1.generate_subenum_domain -- (colors_not_red, colors, enumeration, null_and_not_null, "white", "blue"); -- STEP 8 ***************************************************************************** -- Perform this next step only once after defining all domains -- for a given domain package. This step invokes the generic -- procedure Start_Generation which creates a domain package file -- (named in Step 2) and containing the domain definitions for that -- domain package. begin DOMAIN_1.start_generation; end; -- ************************************************************************************** -- Additional domain packages containing domain definitions here. -- Repeat Steps 5, 6, 7, 8 for each additional domain package. -- STEP 9 ********************************************************************************* -- Perform this step only once. This step invokes the generic procedure, -- Generate_Base_Specific which creates the text file Base_Specific_Domains. DOM_PACKS.generate_base_specific; end PROG; -- ****************************************************************************** -- Template without explanatory comments -- ****************************************************************************** with abstract_domain_generator; with generator_support; use generator_support; procedure PROG is type PACK_NAMES is (ALL VALID DOMAIN PACKAGE NAMES SEPARATED BY COMMAS HERE); package DOM_PACKS is new abstract_domain_generator (PACK_NAMES); begin declare type DOMS is (ALL VALID DOMAIN NAMES SEPARATED BY COMMAS HERE); package DOMAIN_1 is new DOM_PACKS.generate_domain_package (A VALID PACKAGE NAME, DOMS); package FIRST is new domain_1.generate_int_domain (DOMAIN_NAME, DOMAIN_TYPE, NULL_INDICATOR, RANGE_START, RANGE_STOP); package SECOND is new domain_1.generate_subint_domain (DOMAIN_NAME, DOMAIN_BASED_ON, DOMAIN_TYPE, NULL_INDICATOR, RANGE_START, RANGE_STOP); package THIRD is new DOMAIN_1.generate_flt_domain(PARAMETER LIST); (DOMAIN_NAME, DOMAIN_TYPE, NULL_INDICATOR, RANGE_START, RANGE_STOP); package FOURTH is new DOMAIN_1.generate_subflt_domain(PARAMETER LIST); (DOMAIN_NAME, DOMAIN_BASED_ON, DOMAIN_TYPE, NULL_INDICATOR, RANGE_START, RANGE_STOP); type VALS is (LIST OF VALUES SEPARATED BY COMMAS HERE); package FIFTH is new DOMAIN_1.generate_enum_domain(VALS, PARAMETER LIST); (VALS, DOMAIN_NAME, DOMAIN_TYPE, NULL_INDICATOR); package SIXTH is new domain_1.generate_subenum_domain(PARAMETER LIST); (DOMAIN_NAME, DOMAIN_BASED_ON, DOMAIN_TYPE, NULL_INDICATOR, RANGE_START, RANGE_STOP); -- Additional domain definitions here... begin DOMAIN_1.start_generation; end; -- Additional domain packages here... DOM_PACKS.generate_base_specific; end PROG;