File: eaf_n_cst_classdefinitionservice.sru
Size: 16471
Date: Tue, 22 Jan 2008 23:39:23 +0100
$PBExportHeader$eaf_n_cst_classdefinitionservice.sru
forward
global type eaf_n_cst_classdefinitionservice from n_cst_baseservice
end type
end forward

global type eaf_n_cst_classdefinitionservice from n_cst_baseservice
end type
global eaf_n_cst_classdefinitionservice eaf_n_cst_classdefinitionservice

type variables

end variables

forward prototypes
public function long getancestorclasses (string as_classname, ref classdefinition acd_ancestorclasses[])
public function boolean isdescendant (string as_classname, string as_ancestorclassname)
public function boolean isdescendant (classdefinition acd_class, string as_ancestorclassname)
public function boolean isfunctiondefined (string as_classname, string as_functionname, string as_argumentlist[])
public function boolean isfunctiondefined (classdefinition acd_class, string as_functionname, string as_argumentlist[])
public function long getancestorclasses (classdefinition acd_class, ref classdefinition acd_ancestorclasses[])
public function boolean iseventdefined (string as_classname, string as_eventname)
public function boolean iseventdefined (classdefinition acd_class, string as_eventname)
public function boolean isclassexist (string as_classname)
end prototypes

public function long getancestorclasses (string as_classname, ref classdefinition acd_ancestorclasses[]);///////////////////////////////////////////////////////////////////////////////////
// Description:
//    Returns all Ancestor Classdefinitions for the passed in 
//    Classname
// Revisions
//    1.0   - Initial version
// Arguments:  
//    as_classname            - Classname for which to get ancestor classes
//    acd_ancestorclasses[]   - Place holder to hold a list of all ancestors
// Returns: 
//    >0 - The number of ancestor classes
//    -1 - Failure
///////////////////////////////////////////////////////////////////////////////////
// Copyright © 2000 - 2007 Youngsoft, Inc.  All rights reserved.
// Any distribution of the Youngsoft, Inc. Enterprise Application Framework
// source code in whole or part by other than Youngsoft, Inc. is prohibited.
/////////////////////////////////////////////////////////////////////////////////// 

constant string METHOD_NAME = "getAncestorClasses "

If ib_trace and ib_detailed Then
   inv_log.traceLog (METHOD_NAME,  "(as_classname, acd_ancestorclasses[])   " + &
      "as_classname="+as_classname)
End If

// Declare local variables
long              ll_rc
classdefinition   lcd_class

// Validate arguments
If isNull(as_classname) Or len(trim(as_classname)) = 0 Then
   addError(METHOD_NAME,  "Invalid as_classname argument")
   Return -1
End If

// Cast to a classdefinition variable and Validate
lcd_class = findClassDefinition (as_classname)
If isNull(lcd_class) Or Not isValid(lcd_class) Then
   addError(METHOD_NAME,  "Invalid as_classname argument")
   Return -1
End If

ll_rc = getAncestorClasses (lcd_class, acd_ancestorclasses[])
Return ll_rc
end function

public function boolean isdescendant (string as_classname, string as_ancestorclassname);///////////////////////////////////////////////////////////////////////////////////
// Description:
//    Determines if the passed in Classname is a Descendant of
//    the passed in Ancestor Classname
// Revisions
//    1.0   - Initial version
// Arguments:  
//    as_classname         - Classname for which to determine if it is a 
//                            descendant of the Ancestor Classname
//    as_ancestorclassname - Ancestor classname
// Returns: 
//    True if an ancestor
//    False if otherwise or in failure
///////////////////////////////////////////////////////////////////////////////////
// Copyright © 2000 - 2007 Youngsoft, Inc.  All rights reserved.
// Any distribution of the Youngsoft, Inc. Enterprise Application Framework
// source code in whole or part by other than Youngsoft, Inc. is prohibited.
///////////////////////////////////////////////////////////////////////////////////

constant string METHOD_NAME = "isDescendant "

If ib_trace and ib_detailed Then
   inv_log.traceLog (METHOD_NAME,  "(as_classname, as_ancestorclassname)~r~n" + &
      "   as_classname="+as_classname+"~r~n" + &
      "   as_ancestorclassname="+as_ancestorclassname)
End If

boolean           lb_isancestor
classdefinition   lcd_source

// Cast to a classdefinition variable and Validate
lcd_source = findClassDefinition (as_classname)
If isNull(lcd_source) Or Not isValid(lcd_source) Then
   addError(METHOD_NAME,  "Invalid as_classname argument")
   Return false
End If

lb_isancestor = isDescendant (lcd_source, as_ancestorclassname)
Return lb_isancestor
end function

public function boolean isdescendant (classdefinition acd_class, string as_ancestorclassname);///////////////////////////////////////////////////////////////////////////////////
// Description:
//    Determines if the passed in Class is a Descendant of
//    the passed in Classname
// Revisions
//    1.0   - Initial version
// Arguments:  
//    acd_class            - Class for which to determine if it is a 
//                           descendant of the Ancestor classname
//    as_ancestorclassname - Ancestor classname
// Returns: 
//    True if an ancestor
//    False if otherwise or in failure
///////////////////////////////////////////////////////////////////////////////////
// Copyright © 2000 - 2007 Youngsoft, Inc.  All rights reserved.
// Any distribution of the Youngsoft, Inc. Enterprise Application Framework
// source code in whole or part by other than Youngsoft, Inc. is prohibited.
/////////////////////////////////////////////////////////////////////////////////// 

constant string METHOD_NAME = "isDescendant "

If ib_trace Then
   inv_log.traceLog (METHOD_NAME,  "(acd_class, as_ancestorclassname)   " + &
      "as_ancestorclassname="+as_ancestorclassname)
End If

// Declare local variables
classdefinition   lcd_ancestor
classdefinition   lcd_working

// Perform cleanup
as_ancestorclassname = trim(as_ancestorclassname)

// Validate arguments
If isNull (acd_class) Or Not isValid (acd_class) Then
   addError(METHOD_NAME,  "Invalid acd_class argument")
   Return false
End If
If isNull (as_ancestorclassname) Or len(as_ancestorclassname) = 0 Then
   addError(METHOD_NAME,  "Invalid as_ancestorclassname argument")
   Return false
End If

// Cast to a classdefinition variable and Validate
lcd_ancestor = findClassDefinition (as_ancestorclassname)
If isNull(lcd_ancestor) Or Not isValid(lcd_ancestor) Then
   addError(METHOD_NAME,  "Invalid as_sourceclassname argument")
   Return false
End If

// -- Loop checking to see if an ancestor match is found
// Get the first ancestor
lcd_working = acd_class.ancestor
Do while isValid (lcd_working)
   // Check for a match
   If lcd_working.name = lcd_ancestor.name Then
      // The matching ancestor has been found
      Return true
   End If

   // Get the next ancestor
   lcd_working = lcd_working.ancestor
Loop

// No matching ancestor was found
Return false
end function

public function boolean isfunctiondefined (string as_classname, string as_functionname, string as_argumentlist[]);///////////////////////////////////////////////////////////////////////////////////
// Description:
//    Determines if the passed in Function Name is found in the passed
//    in Classname
// Revisions
//    1.0   - Initial version
// Arguments:  
//    as_classname      - Classname to check on for the function
//    as_functionname   - The function to check for
//    as_argumentlist[] - The arguments on the function
// Returns: 
//    True if function is found
//    False otherwise (including failure)
///////////////////////////////////////////////////////////////////////////////////
// Copyright © 2000 - 2007 Youngsoft, Inc.  All rights reserved.
// Any distribution of the Youngsoft, Inc. Enterprise Application Framework
// source code in whole or part by other than Youngsoft, Inc. is prohibited.
/////////////////////////////////////////////////////////////////////////////////// 

constant string METHOD_NAME = "isFunctionDefined "

If ib_trace and ib_detailed Then
   inv_log.traceLog (METHOD_NAME,  "(as_classname, as_functionname, as_argumentlist[])~r~n" + &
      "as_classname="+as_classname+"~r~n" + &
      "as_functionname="+as_functionname)
End If

// Declare local variables
boolean           lb_isdefined
classdefinition   lcd_class

// Perform cleanup
as_classname = trim(as_classname)
as_functionname = trim(as_functionname)

// Validate arguments
If isNull(as_classname) Or len(as_classname) = 0 Then
   addError(METHOD_NAME,  "Invalid as_classname argument")
   Return false
End If
If isNull(as_functionname) Or len(as_functionname) = 0 Then
   addError(METHOD_NAME,  "Invalid as_functionname argument")
   Return false
End If

// Cast to a classdefinition variable and Validate
lcd_class = findClassDefinition (as_classname)
If isNull(lcd_class) Or Not isValid(lcd_class) Then
   addError(METHOD_NAME,  "Invalid as_classname argument")
   Return false
End If

lb_isdefined = isFunctionDefined (lcd_class, as_functionname, as_argumentlist[])
Return lb_isdefined
end function

public function boolean isfunctiondefined (classdefinition acd_class, string as_functionname, string as_argumentlist[]);///////////////////////////////////////////////////////////////////////////////////
// Description:
//    Determines if the passed in Function Name is found in the 
//    passed in Class
// Revisions
//    1.0   - Initial version
// Arguments:  
//    acd_class            - Class to check on for the function
//    as_functionname      - The function to check for
//    as_argumentlist[]    - The arguments on the function
// Returns: 
//    True if function is found
//    False otherwise (including failure)
///////////////////////////////////////////////////////////////////////////////////
// Copyright © 2000 - 2007 Youngsoft, Inc.  All rights reserved.
// Any distribution of the Youngsoft, Inc. Enterprise Application Framework
// source code in whole or part by other than Youngsoft, Inc. is prohibited.
/////////////////////////////////////////////////////////////////////////////////// 

constant string METHOD_NAME = "isFunctionDefined "

If ib_trace Then
   inv_log.traceLog (METHOD_NAME,  "(acd_class, as_functionname, as_argumentlist[])~r~n" + &
      "as_functionname="+as_functionname)
End If

// Declare local variables
boolean           lb_found
scriptdefinition  lscrd_possiblefunctionmatch

// Perform cleanup
as_functionname = trim(as_functionname)

// Validate arguments
If isNull(acd_class) Or Not isValid(acd_class) Then
   addError (METHOD_NAME,  "Invalid acd_class argument")
   Return false
End If

// Attempt to find a matching function
lscrd_possiblefunctionmatch = &
   acd_class.findMatchingFunction (as_functionname, as_argumentlist[])
If isNull(lscrd_possiblefunctionmatch) Or &
      Not isValid (lscrd_possiblefunctionmatch) Then
   Return false
End If

Return true
end function

public function long getancestorclasses (classdefinition acd_class, ref classdefinition acd_ancestorclasses[]);///////////////////////////////////////////////////////////////////////////////////
// Description:
//    Returns all Ancestor Classdefinitions for the passed in Class
// Revisions
//    1.0   - Initial version
// Arguments:  
//    acd_class               - Class for which to get ancestor classes
//    acd_ancestorclasses[]   - Place holder to hold a list of all ancestors
// Returns: 
//    >0 - The number of ancestor classes
//    -1 - Failure
///////////////////////////////////////////////////////////////////////////////////
// Copyright © 2000 - 2007 Youngsoft, Inc.  All rights reserved.
// Any distribution of the Youngsoft, Inc. Enterprise Application Framework
// source code in whole or part by other than Youngsoft, Inc. is prohibited.
/////////////////////////////////////////////////////////////////////////////////// 

constant string METHOD_NAME = "getAncestorClasses "

inv_log.traceLog (METHOD_NAME,  "(acd_class, acd_ancestorclasses[])")

// Declare local variables
long              ll_upper
classdefinition   lcd_working
classdefinition   lcd_empty[]

// Perform cleanup
acd_ancestorclasses[] = lcd_empty[]

// Validate arguments
If isNull(acd_class) Or Not isValid (acd_class) Then
   addError(METHOD_NAME,  "Invalid acd_class argument")
   Return -1
End If

// -- Loop around getting the ancestor classes
// Get the first possible ancestor
lcd_working = acd_class.ancestor
Do While isValid (lcd_working)
   // Found an ancestor
   ll_upper ++ 
   acd_ancestorclasses[ll_upper] = lcd_working
   
   // Get the next possible ancestor
   lcd_working = lcd_working.ancestor
Loop

Return ll_upper
end function

public function boolean iseventdefined (string as_classname, string as_eventname);///////////////////////////////////////////////////////////////////////////////////
// Description:
//    Determines if the passed in Event Name is found in the passed
//    in Classname 
// Revisions
//    1.0   - Initial version
// Arguments:  
//    as_classname   - Classname on which to check for the event
//    as_eventname   - The event to check for
// Returns: 
//    True if event is found
//    False otherwise (including failure)
///////////////////////////////////////////////////////////////////////////////////
// Copyright © 2000 - 2007 Youngsoft, Inc.  All rights reserved.
// Any distribution of the Youngsoft, Inc. Enterprise Application Framework
// source code in whole or part by other than Youngsoft, Inc. is prohibited.
/////////////////////////////////////////////////////////////////////////////////// 

constant string METHOD_NAME = "isEventDefined "

If ib_trace and ib_detailed Then
   inv_log.traceLog (METHOD_NAME,  "(as_classname, as_eventname)   " + &
      "as_eventname="+as_eventname)
End If

// Declare local variables
boolean           lb_isdefined
classdefinition   lcd_class

// Cast to a classdefinition variable and Validate
lcd_class = findClassDefinition (as_classname)
If isNull(lcd_class) Or Not isValid(lcd_class) Then
   addError(METHOD_NAME,  "Invalid as_classname argument")
   Return false
End If

lb_isdefined = isEventDefined (lcd_class, as_eventname)
Return lb_isdefined
end function

public function boolean iseventdefined (classdefinition acd_class, string as_eventname);///////////////////////////////////////////////////////////////////////////////////
// Description:
//    Determines if the passed in Event Name is found in the passed
//    in Class
// Revisions
//    1.0   - Initial version
// Arguments:  
//    acd_class         - The class to check on for the event
//    as_eventname      - The event to check for
// Returns: 
//    True if event is found
//    False otherwise (including failure)
///////////////////////////////////////////////////////////////////////////////////
// Copyright © 2000 - 2007 Youngsoft, Inc.  All rights reserved.
// Any distribution of the Youngsoft, Inc. Enterprise Application Framework
// source code in whole or part by other than Youngsoft, Inc. is prohibited.
/////////////////////////////////////////////////////////////////////////////////// 

constant string METHOD_NAME = "isEventDefined "

If ib_trace Then
   inv_log.traceLog (METHOD_NAME,  "(acd_class, as_eventname)   " + &
      "as_eventname="+as_eventname)
End If      

// Declare local variables
long              ll_upper
long              ll_idx

// Perform cleanup
as_eventname = trim(as_eventname)

// Validate arguments
If isNull(acd_class) Or Not isValid(acd_class) Then
   addError (METHOD_NAME,  "Invalid acd_class argument")
   Return false
End If
If isNull(as_eventname) Or len(as_eventname) = 0 Then
   addError (METHOD_NAME,  "Invalid as_eventname argument")
   Return false
End If

// Loop for a matching event signature
ll_upper = upperBound (acd_class.scriptlist)
For ll_idx = 1 to ll_upper
   // Check for a matching signature
   If acd_class.scriptlist[ll_idx].name = as_eventname And &
         acd_class.scriptlist[ll_idx].kind = scriptevent! Then
      // An event with the same signature was found
      Return true
   End If
Next

// Matching event was Not found
Return false
end function

public function boolean isclassexist (string as_classname);ClassDefinition lclassdef

lclassdef = FindClassDefinition(as_classname)

if ISNULL(lclassdef) then
   return false
else
   return true
end if


end function

on eaf_n_cst_classdefinitionservice.create
call super::create
end on

on eaf_n_cst_classdefinitionservice.destroy
call super::destroy
end on