100 likes | 239 Views
Composition Steps. 01/10/2013. Agenda. Retooling note Define composition Wrapper without function pointer Compositions (thus far ) Evolutionary computation discussion. Retooling. Issue found with codebase Compiled with .cc extension defaulted to g++
E N D
Composition Steps 01/10/2013
Agenda • Retooling note • Define composition • Wrapper without function pointer • Compositions (thus far) • Evolutionary computation discussion
Retooling • Issue found with codebase • Compiled with .cc extension defaulted to g++ • Can’t use member functions in structs in C • Code moved to a “proper” C implementation that compiles with gcc
Define Composition • Standard definition: • “has-a” • Implies ownership from parent class • Destroyed when parent is destroyed • Will we have cases where this implication is not valid • i.e. aggregation?
Wrapper - No Function Pointer • Wrapper function called from main • Passed in target data structure • Wrapper implements Sorter class • Calls merge sort directly • Copies over sorted data into target data structure upon completion
Composition Steps • Function pointer (same return type / parameters) • Add function pointer to data producer struct • Pass in algorithm function to struct • Ensure that data is either formatted in place or handled after called
Composition Steps • Function pointer (different return types / parameters) • Similar approach to previous • Create wrapper that matches function pointer • Call necessary function inside wrapper • Ensure data is copied correctly
Composition Steps • Wrapper without function pointer • Instantiate struct in wrapper function • Call desired algorithm directly in wrapper • Copy data over into desired data consumer
eBook Find • Object-Oriented Programming with ANSI-C • http://www.cs.rit.edu/~ats/books/ooc.pdf • Discusses methods for implementing OO concepts in ANSI-C • Inheritance • Polymorphism • Delegation • Etc. • Plan is to migrate the simple Sorting struct into a framework that can support some of the design patterns presented as-is • Wrapper • Strategy
Evolutionary Computation Discussion • Looking into framework development as we develop our genome • Developing infrastructure • Genome data structure • If genetic programming, stack or tree • If genetic algorithm, vector or array • Any limitations on language for EC program? • Evolved programs must be C-compilable, however can we use C++ for the infrastructure?