1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139
|
module Base_mod
public :: Base
type,abstract :: Base
character(len=10) :: s
contains
procedure :: printb
end type
contains
subroutine printb(this)
class(Base),intent(in) :: this
print*,this%s
end subroutine
end module Base_mod
module Derive1_mod
use Base_mod
public :: Derive1
type,extends(Base) :: Derive1
end type
interface Derive1
module procedure newDerive1
end interface
contains
function newDerive1(s1) result(d1)
character(len=*),intent(in) ::s1
type(Derive1) :: d1
d1%s = trim(s1)
end function
end module Derive1_mod
module Derive2_mod
use Base_mod
public :: Derive2
type,extends(Base) :: Derive2
end type
interface Derive2
module procedure newDerive2
end interface
contains
function newDerive2(s2) result(d2)
character(len=*),intent(in) :: s2
type(Derive2) :: d2
d2%s = trim(s2)
end function
end module Derive2_mod
module StringPoly_mod
use Base_mod
#define _key_string_deferred
#define _key_equal_defined
#define _key_less_than_defined
#define _value class(Base)
#define _value_allocatable
#define _alt
#include "templates/map.inc"
end module StringPoly_mod
module tracer_mod
use Derive1_mod
use Derive2_mod
use StringPoly_mod,only : StringPolyMap=>map,StringMapIterator=>MapIterator
implicit none
type :: Tracer
type(StringPolyMap) :: aSmap
contains
end type
end module
module TracerMap_mod
use Tracer_mod
#define _key_string_deferred
#define _key_equal_defined
#define _Key_less_than_defined
#define _value class(Tracer)
#define _value_allocatable
#define _alt
#include "templates/map.inc"
end module TracerMap_mod
module TracerBundle_mod
use Tracer_mod
use TracerMap_mod,TracerMap=>Map
implicit none
type :: TracerBundle
type(TracerMap) :: aTmap
contains
end type
end module TracerBundle_mod
program main
use Derive1_mod
use Derive2_mod
use StringPoly_mod
use Tracer_mod
use TracerMap_mod,TracerMapIterator=>MapIterator
use TracerBundle_mod
implicit none
type (StringPolyMap) :: m
type (StringMapIterator) :: mp
class(Base) ,pointer :: p
type(Tracer) :: aTrcer
type(Tracer),pointer :: aTp
type(TracerBundle) :: aBundle
type(TracerMapIterator) :: iter
call m%insert('d1',Derive1('1Derive1'))
call m%insert('d2',Derive2('1Derive2'))
p=>m%at('d1')
call p%printb()
p=>m%at('d2')
call p%printb()
mp = m%find('d1')
print*,mp%key()
call aTrcer%aSmap%insert('d1',Derive1('1Derive1'))
call aBundle%aTmap%insert('firstT',aTrcer)
iter = aBundle%aTmap%begin()
print*,iter%key()
aTp=>iter%value()
p=>aTp%aSmap%at('d1')
call p%printb()
end program main
|