Skip to content

Instantly share code, notes, and snippets.

@swoogles
Last active December 28, 2015 06:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save swoogles/7457461 to your computer and use it in GitHub Desktop.
Save swoogles/7457461 to your computer and use it in GitHub Desktop.
Random File
control_center.h
variables:
puOneShot * dec_dt_button;
methods
static void alterDT(puObject *);
void init( boost::shared_ptr<Simulation> residentSimulation );
-----------------------
control_center.cpp
void control_center::alterDT(puObject * caller) {
cout << "\nRetrieving user Data from caller" <<endl;
boost::shared_ptr<Simulation> * spPointer = (boost::shared_ptr<Simulation> *)caller->getUserData();
if ( spPointer == NULL )
{
cout << "Retrievd a stupid null value from puObject!" << endl;
}
// cout << "Control_center.simulation.dt: " << spPointer->getDT() << endl;
boost::shared_ptr<Simulation> curSimulation = boost::shared_ptr<Simulation>( *spPointer );
cout << "Control_center.simulation.dt: " << curSimulation->getDT() << endl;
}
void control_center::init( boost::shared_ptr<Simulation> residentSimulation ) {
...
dec_dt_button = new puOneShot(curX, curHeight - elementHeight, curX+placementWidth, curHeight);
curX += (placementWidth +gap);dec_dt_button->setLegend("Slower");
cout << "About to set user Data" << endl;
cout << "residentSimulation: " << residentSimulation << endl;
cout << "residentSimulation->dt: " << residentSimulation->getDT() << endl;
dec_dt_button->setUserData( &residentSimulation );
dec_dt_button->setCallback( alterDT );
boost::shared_ptr<Simulation> * spPointer = (boost::shared_ptr<Simulation> *)dec_dt_button->getUserData();
cout << "\nRetrieving user Data from dec_dt_button after setting callback" << endl;
if ( spPointer == NULL )
{
cout << "Retrievd a stupid null value from dec_dt_button!" << endl;
}
cout << "userData: " << *spPointer << endl;
cout << "userData->dt: " << (*spPointer)->getDT() << endl;
...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment