ECOBUF ;BP/CMF - Factory Object
;;2.0;EVENT CAPTURE;**100,107**;8 May 96;Build 14
;@author - Chris Flegel
;@date - 17 May 2009
;@version - 1.0
;;
Q
;; private methods
;;
FACTORY0() Q "^TMP($J,""ECOBUF"")"
;;
FACTORY1() Q "^TMP($J,""ECOBUF"",1)"
;;
FACTORY2() ;
S ^XTMP("ECOBUF",0)=$G(DT)+1_"^"_$G(DT)
Q "^XTMP(""ECOBUF"","_$S($G(DUZ)'="":DUZ,$G(DT)'="":DT,1:1)_")"
;;
VALUE(VALUE) ;; parse "." out of Parameter values
Q $S(VALUE="":"",1:$P(VALUE,".")_U_$P(VALUE,".",2,3))
;;
;; published methods
FACTORY(RESULT,ARGUMENT) ; wrapper for factory methods - RPC "EC OBU FACTORY"
N FACTORY,HANDLE,CREATE,DESTROY,CLASS,NAME,TARGET
N ARG1,ARG2,ARG3
S RESULT="-1^Invalid Factory Parameters",RESULT(0)=RESULT
S ARGUMENT=$G(ARGUMENT)
Q:ARGUMENT=""
S ARG1=$P(ARGUMENT,".",1)
S ARG2=$P(ARGUMENT,".",2)
S ARG3=$P(ARGUMENT,".",3)
S ARG3=$S(ARG3'="":ARG3,ARG1="Constructor"&(ARG3=""):$$FACTORY2(),1:"")
Q:ARG1="Constructor"&(ARG3="")
I ARG1="Constructor" D Q
.S CLASS=ARG2
.S NAME=ARG3
.S CREATE=$$GET^XPAR("PKG","ECOB CONSTRUCTOR",CLASS,"E")
.I CREATE="" S RESULT(0)="-1^Invalid Class Name" S RESULT=RESULT(0) Q
.S CREATE="S RESULT=$$"_$$VALUE(CREATE)
.X CREATE
.S RESULT(0)=RESULT
.Q
I ARG1="Destructor" D Q
.S TARGET=ARG2
.I ARG3'="" S CLASS=ARG3
.E D METHOD(.CLASS,TARGET_".of.Get_class")
.S DESTROY=$$GET^XPAR("PKG","ECOB DESTRUCTOR",CLASS,"E")
.I DESTROY="" S RESULT(0)="-1^Invalid Class Name" S RESULT=RESULT(0) Q
.S DESTROY="S RESULT=$$"_$$VALUE(DESTROY)
.S HANDLE=TARGET
.X DESTROY
.S RESULT(0)=RESULT
.Q
I ARG1="Method" D Q
.D METHOD(.RESULT,$P(ARGUMENT,".",2,99))
.S RESULT(0)=RESULT
.Q
Q
;;
METHOD(RESULT,ARGUMENT) ;
; call parent last
D METHOD^ECOBU(.RESULT,ARGUMENT) ; parent method
S RESULT(0)=RESULT
Q
METHODS(RESULT,ARGUMENT) ;
; call parent last
D METHOD^ECOBU(.RESULT,ARGUMENT) ; parent method
Q
OUT(ARGUMENT) ;method call as function
N RESULT
D METHOD(.RESULT,ARGUMENT)
Q RESULT
--- Routine Detail --- with STRUCTURED ROUTINE LISTING ---[H[J[2J[HECOBUF 2031 printed Nov 22, 2024@17:08:19 Page 2
ECOBUF ;BP/CMF - Factory Object
+1 ;;2.0;EVENT CAPTURE;**100,107**;8 May 96;Build 14
+2 ;@author - Chris Flegel
+3 ;@date - 17 May 2009
+4 ;@version - 1.0
+5 ;;
+6 QUIT
+7 ;; private methods
+8 ;;
FACTORY0() QUIT "^TMP($J,""ECOBUF"")"
+1 ;;
FACTORY1() QUIT "^TMP($J,""ECOBUF"",1)"
+1 ;;
FACTORY2() ;
+1 SET ^XTMP("ECOBUF",0)=$GET(DT)+1_"^"_$GET(DT)
+2 QUIT "^XTMP(""ECOBUF"","_$SELECT($GET(DUZ)'="":DUZ,$GET(DT)'="":DT,1:1)_")"
+3 ;;
VALUE(VALUE) ;; parse "." out of Parameter values
+1 QUIT $SELECT(VALUE="":"",1:$PIECE(VALUE,".")_U_$PIECE(VALUE,".",2,3))
+2 ;;
+3 ;; published methods
FACTORY(RESULT,ARGUMENT) ; wrapper for factory methods - RPC "EC OBU FACTORY"
+1 NEW FACTORY,HANDLE,CREATE,DESTROY,CLASS,NAME,TARGET
+2 NEW ARG1,ARG2,ARG3
+3 SET RESULT="-1^Invalid Factory Parameters"
SET RESULT(0)=RESULT
+4 SET ARGUMENT=$GET(ARGUMENT)
+5 if ARGUMENT=""
QUIT
+6 SET ARG1=$PIECE(ARGUMENT,".",1)
+7 SET ARG2=$PIECE(ARGUMENT,".",2)
+8 SET ARG3=$PIECE(ARGUMENT,".",3)
+9 SET ARG3=$SELECT(ARG3'="":ARG3,ARG1="Constructor"&(ARG3=""):$$FACTORY2(),1:"")
+10 if ARG1="Constructor"&(ARG3="")
QUIT
+11 IF ARG1="Constructor"
Begin DoDot:1
+12 SET CLASS=ARG2
+13 SET NAME=ARG3
+14 SET CREATE=$$GET^XPAR("PKG","ECOB CONSTRUCTOR",CLASS,"E")
+15 IF CREATE=""
SET RESULT(0)="-1^Invalid Class Name"
SET RESULT=RESULT(0)
QUIT
+16 SET CREATE="S RESULT=$$"_$$VALUE(CREATE)
+17 XECUTE CREATE
+18 SET RESULT(0)=RESULT
+19 QUIT
End DoDot:1
QUIT
+20 IF ARG1="Destructor"
Begin DoDot:1
+21 SET TARGET=ARG2
+22 IF ARG3'=""
SET CLASS=ARG3
+23 IF '$TEST
DO METHOD(.CLASS,TARGET_".of.Get_class")
+24 SET DESTROY=$$GET^XPAR("PKG","ECOB DESTRUCTOR",CLASS,"E")
+25 IF DESTROY=""
SET RESULT(0)="-1^Invalid Class Name"
SET RESULT=RESULT(0)
QUIT
+26 SET DESTROY="S RESULT=$$"_$$VALUE(DESTROY)
+27 SET HANDLE=TARGET
+28 XECUTE DESTROY
+29 SET RESULT(0)=RESULT
+30 QUIT
End DoDot:1
QUIT
+31 IF ARG1="Method"
Begin DoDot:1
+32 DO METHOD(.RESULT,$PIECE(ARGUMENT,".",2,99))
+33 SET RESULT(0)=RESULT
+34 QUIT
End DoDot:1
QUIT
+35 QUIT
+36 ;;
METHOD(RESULT,ARGUMENT) ;
+1 ; call parent last
+2 ; parent method
DO METHOD^ECOBU(.RESULT,ARGUMENT)
+3 SET RESULT(0)=RESULT
+4 QUIT
METHODS(RESULT,ARGUMENT) ;
+1 ; call parent last
+2 ; parent method
DO METHOD^ECOBU(.RESULT,ARGUMENT)
+3 QUIT
OUT(ARGUMENT) ;method call as function
+1 NEW RESULT
+2 DO METHOD(.RESULT,ARGUMENT)
+3 QUIT RESULT