@@ -15,10 +15,17 @@ module wenoof_base_object
1515
1616type, abstract :: base_object_constructor
1717 ! < Abstract base object constructor.
18- integer (I_P) :: S= 0_I_P ! < Stencils dimension.
19- real (R_P) :: eps= EPS_DEF ! < Small epsilon to avoid division by zero.
18+ integer (I_P) :: S= 0_I_P ! < Stencils dimension.
19+ real (R_P) :: eps= EPS_DEF ! < Small epsilon to avoid division by zero.
2020 contains
21+ ! public methods
2122 procedure , pass(self) :: create = > create_base_object_constructor
23+ ! public operators
24+ generic :: assignment (= ) = > constr_assign_constr ! < `=` overloading.
25+ ! public deferred methods
26+ procedure (constr_assign_constr_interface), pass(lhs), deferred :: constr_assign_constr ! < `=` operator.
27+ ! public non overridable methods
28+ procedure , pass(lhs), non_overridable :: assign_ = > assign_constr_ ! < Assign object.
2229endtype base_object_constructor
2330
2431type, abstract :: base_object
@@ -28,17 +35,38 @@ module wenoof_base_object
2835 integer (I_P) :: S= 0_I_P ! < Stencils dimension.
2936 real (R_P) :: eps= EPS_DEF ! < Small epsilon to avoid division by zero.
3037 contains
38+ ! public operators
39+ generic :: assignment (= ) = > object_assign_object ! < `=` overloading.
3140 ! public deferred methods
32- procedure (create_interface), pass(self), deferred :: create ! < Create object.
33- procedure (description_interface), pass(self), deferred :: description ! < Return object string-description.
34- procedure (destroy_interface), pass(self), deferred :: destroy ! < Destroy object.
41+ procedure (create_interface), pass(self), deferred :: create ! < Create object.
42+ procedure (description_interface), pass(self), deferred :: description ! < Return object string-description.
43+ procedure (destroy_interface), pass(self), deferred :: destroy ! < Destroy object.
44+ procedure (object_assign_object_interface), pass(lhs), deferred :: object_assign_object ! < `=` operator.
3545 ! public non overridable methods
46+ procedure , pass(lhs), non_overridable :: assign_ ! < Assign object.
3647 procedure , pass(self), non_overridable :: create_ ! < Create object.
3748 procedure , pass(self), non_overridable :: destroy_ ! < Destroy object.
3849endtype base_object
3950
51+ abstract interface
52+ ! < Abstract interfaces of [[base_object_constructor]].
53+ subroutine constr_assign_constr_interface (lhs , rhs )
54+ ! < `=` operator.
55+ import :: base_object_constructor
56+ class(base_object_constructor), intent (inout ) :: lhs ! < Left hand side.
57+ class(base_object_constructor), intent (in ) :: rhs ! < Right hand side.
58+ end subroutine constr_assign_constr_interface
59+ endinterface
60+
4061abstract interface
4162 ! < Abstract interfaces of [[base_object]].
63+ subroutine object_assign_object_interface (lhs , rhs )
64+ ! < `=` operator.
65+ import :: base_object
66+ class(base_object), intent (inout ) :: lhs ! < Left hand side.
67+ class(base_object), intent (in ) :: rhs ! < Right hand side.
68+ end subroutine object_assign_object_interface
69+
4270 subroutine create_interface (self , constructor )
4371 ! < Create object.
4472 ! <
@@ -77,9 +105,28 @@ subroutine create_base_object_constructor(self, S, eps)
77105 if (present (eps)) self% eps = eps
78106 end subroutine create_base_object_constructor
79107
108+ ! public non overridable methods
109+ subroutine assign_constr_ (lhs , rhs )
110+ ! < Assign object constructor.
111+ class(base_object_constructor), intent (inout ) :: lhs ! < Left hand side.
112+ class(base_object_constructor), intent (in ) :: rhs ! < Right hand side.
113+
114+ lhs% S = rhs% S
115+ lhs% eps = rhs% eps
116+ end subroutine assign_constr_
117+
80118 ! base object
81119
82120 ! public non overridable methods
121+ subroutine assign_ (lhs , rhs )
122+ ! < Assign object.
123+ class(base_object), intent (inout ) :: lhs ! < Left hand side.
124+ class(base_object), intent (in ) :: rhs ! < Right hand side.
125+
126+ lhs% S = rhs% S
127+ lhs% eps = rhs% eps
128+ end subroutine assign_
129+
83130 subroutine create_ (self , constructor )
84131 ! < Create object.
85132 class(base_object), intent (inout ) :: self ! < Object.
0 commit comments