Upcoming SlideShare
×

Like this presentation? Why not share!

on Jul 29, 2009

• 350 views

These are some more advanced concepts in the dynamic polymorphic object design paradigm

These are some more advanced concepts in the dynamic polymorphic object design paradigm

Views

Total Views
350
Views on SlideShare
347
Embed Views
3

Likes
0
0
0

Report content

• Comment goes here.
Are you sure you want to
• You don’t have to touch the camera’s display list when you are messing with individual elements of the HUD object.
• Functors allow
• The parameter list typically contains a single CObject, the ‘this’ object. If it contained more objects, the functor would operate on those objects, too.
• High level functor operation
• High level functor operation

• List Objects
• Make a CLinkList into a CObject
• Now lists can be manipulated like CObjects!
• Oh God no. Why?
• A list of lists is useful
• Passing a list as an argument to a function is useful
• List of lists allows a tree to have branches as well as leaves
• Don’t need to add lists together when we have a list of lists. Just traverse the elements of the list of lists.
• Examples of List Objects
• Small display list for a HUD element
• List of triangles in an Octree leaf
• Arguments to a functor (later advanced concept)
• Camera display lists
• List of global lists available
• List of menu lists (future architecture)
• HUD element example HUD Display List HUD Display List A = Shell_dragonWidget A B = Green Dragon Icon B A = Shell_dragonWidget A C C = Red Dragon Icon
• HUD Display List HUD element example continued Camera Display List E F G H A A = Shell_dragonWidget C C = Red Dragon Icon
• Camera Display List G Complex Menu Display List C E D B F J M Z A H Complex Subelement Mini-Display List
• Functors
• Functions can be made into CObjects
• Now functions can be manipulated like CObjects!
• Procedural programming? So last millenium!
• C++ Object-Oriented? No, it’s STATICALLY Object-Oriented
• That’s why they use ‘static’ 8 million times
• CObject Functors are added to each individual CObject Functor List F1 F2
• Functor Calling Conventions
• Other arguments passed depends upon how the Functor is constructed and what arguments it needs
CObj Automatic Argument List
• Each Functor has a default argument list
CObj Functor List Fn
• Each Cobject has its own list of Functors
• The first argument in the Argument List is the Cobject itself. This allows the global Functor to access the ‘this’ pointer.
• Getting a Functor CObj CObj Functor List F1 F2 CFunctor *pFunc = CObj->FindFunctor(“F2”); OR CFunctor *pFunc = CObj->FindFunctor(cobj_functor_type); F2
• Execute the Functor
• Functors operate in 2 ways
• On a list attached to the functor itself (parameter list)
• On a list provided to the functor
• Why does Functor execute have 2 different modes of operation?
• A Functor with an arglist performs a binary operation (ie. C = A+B, “Attach”)
• A Functor without an arglist performs a unary operation using its parameter list as its arguments (ie. A = -A, “Render”, “Instantiate”, “Materialize”, “Animate”)
• The Functor’s operation is performed on each CObject in the list.
• Warning: NO SAFETY CHECKS
• Functor operations are very versatile.
• You can write code to violate the argument passing conventions.