Permalink
Browse files

Prototype get child count method for lo_elements

  • Loading branch information...
hovo1990 committed Jul 23, 2016
1 parent f161d44 commit 1d0b2fb29e166e13660a69cfff7fcfaf74a1bd80
@@ -414,6 +414,10 @@ def write_general_functions(self):
code = gen_functions.write_get_allows_children()
self.write_function_implementation(code)
code = gen_functions.write_get_child_count()
self.write_function_implementation(code)
code = gen_functions.write_hashcode()
self.write_function_implementation(code)
@@ -315,6 +315,98 @@ def write_get_child_at(self):
########################################################################
# Function for writing getChildCount
def create_if_for_get_child_count(self, lo_element):
name = lo_element['name']
cap_name = lo_element['capAttName']
implementation = []
implementation.append('isSetListOf{0}s'.format(cap_name))
implementation.append('count++')
temp_code = self.create_code_block('if', implementation)
return temp_code
def write_get_child_count(self):
if len(self.child_lo_elements) == 0:
return
# do not write for C API
if self.is_java_api is False:
return
# create doc string header
function = 'getChildCount'
title_line = '(non-Javadoc)--@see org.sbml.jsbml.AbstractSBase#getChildCount()'
params = []
return_lines = []
additional = []
additional.append('Override')
# create function decl
return_type = 'int'
arguments = []
# create the function implementation
constructor_args = [] # arguments #self.write_copy_constructor_args(self)
code = []
clone = 'clone'
implementation = []
implementation.append('int count = super.getChildCount()')
code.append(self.create_code_block('line', implementation))
# additional_add, class_key, function_args = jsbmlHelperFunctions.determine_override_or_deprecated(
# self.jsbml_methods,
# function=function,
# return_type=return_type)
#
# if additional_add is not None:
# additional.append(additional_add)
# title_line = jsbmlHelperFunctions.get_javadoc_comments_and_state(additional_add, class_key,
# function, function_args)
for i in range(0, len(self.child_lo_elements)):
lo_element = self.child_lo_elements[i]
temp_code = self.create_if_for_get_child_count(lo_element)
code.append(temp_code)
# temp = ['return hashCode']
# code.append(self.create_code_block('line', temp))
implementation = ['return count']
code.append(self.create_code_block('line', implementation))
return dict({'title_line': title_line,
'params': params,
'return_lines': return_lines,
'additional': additional,
'function': function,
'return_type': return_type,
'arguments': arguments,
'constant': False,
'virtual': False,
'object_name': self.object_name,
'implementation': code,
'constructor_args': constructor_args})
########################################################################
# function for writing get allows children
def write_get_allows_children(self):
if len(self.child_lo_elements) == 0:
return

0 comments on commit 1d0b2fb

Please sign in to comment.