int
main()
{
	A* obj = jnew D();
	obj->foo();
	B* b = dynamic_cast<B*>(obj);
	b->foo();
	D* d = dynamic_cast<D*>(obj);
	d->foo();

	t1.Listen(&t3);
	t2.Listen(&t3);
	JOrderedSetT::Sorted msg;
	t3.Bcast(msg);

	Test* t4 = &t1;
	std::cout << t4 << std::endl;
	clearPointer((void*) &t4);
	std::cout << t4 << std::endl;

	return 0;
}
Ejemplo n.º 2
0
void
GPIOEIntHandler(void)
{
	// Method for handling directional pad interrupts. The left and right
	// buttons allow the user to move the alphabet cursor left and right. This
	// behavior is handled here.

	// Clear the GPIO interrupt
	GPIOPinIntClear(GPIO_PORTE_BASE, GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3);

	// Disable Interrupts
	GPIOPinIntDisable(GPIO_PORTE_BASE, GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3);

	if (state==0){
		while(GPIOPinRead(GPIO_PORTE_BASE, GPIO_PIN_0)==0 ||
			GPIOPinRead(GPIO_PORTE_BASE, GPIO_PIN_1)==0){
			// Increment the counter
			x++;
			if (x>19999){
				if (GPIOPinRead(GPIO_PORTE_BASE, GPIO_PIN_0)==0){
					if (pointer!=0){
						clearPointer(50+(pointer*10));
						pointer--;
						drawPointer(50+(pointer*10));
					}
					x = 0;
					break;
				}
				if (GPIOPinRead(GPIO_PORTE_BASE, GPIO_PIN_1)==0){
					if (pointer!=3){
						clearPointer(50+(pointer*10));
						pointer++;
						drawPointer(50+(pointer*10));
					}
					x = 0;
					break;
				}
			}
		}
		x = 0;
	}
	else if (state==1 || state==3){
		// Count to 15000 so that we don't move the cursor too fast
		while(GPIOPinRead(GPIO_PORTE_BASE, GPIO_PIN_2)==0 ||
				GPIOPinRead(GPIO_PORTE_BASE, GPIO_PIN_3)==0){
			// Increment the counter
			x++;
			if (x>14999){
				// Check to see which button was pressed
				if (GPIOPinRead(GPIO_PORTE_BASE, GPIO_PIN_2)==0){
					// Check if the cursor is not in the original position on the
					// top row. If it is, we do nothing
					if (position>0){
						// Check if the cursor is not in the original position on
						// the bottom row
						if (position2>0){
							// Move the cursor one spot to the left
							position2--;
						}
						else {
							// Move the cursor one spot to the left
							position--;
						}
					}
				}
				else if (GPIOPinRead(GPIO_PORTE_BASE, GPIO_PIN_3)==0){
					// Check if the cursor is at the last possible position on the
					// bottom row. If it is, we do nothing
					if (position2<12){
						// Check if the cursor is at the last spot on the top row
						if (position<13){
							// Move the cursor one spot to the right
							position++;
						}
						else {
							// Move the cursor one spot to the right
							position2++;
						}
					}
				}
				// Update the position of the cursor
				moveCursor();
				break;
			}
		}
		x = 0;
	}

	// Enable Interrupts
	GPIOPinIntEnable(GPIO_PORTE_BASE, GPIO_PIN_0 | GPIO_PIN_1 | GPIO_PIN_2 | GPIO_PIN_3);
}