// file: $isip/doc/examples/class/mmedia/mmedia_example_03/example.cc
//

// isip include files
//
#include <Anchor.h>
#include <Console.h>

// this example demonstrates how to use the Anchor object
//
int main(int argc, const char** argv) {

  // declare anchor objects
  //
  String name_00(L"Anchor00");
  String unit_00(L"seconds");
  
  Anchor ancr_00(name_00, (float)0.1, unit_00);

  // verify that the id has been set
  //
  if (!ancr_00.getId().eq(name_00)) {
    Console::put(L"invalid identifier\n");
  }

  // verify that the offset has been set
  //
  if (!Integral::almostEqual(ancr_00.getOffset(), (float)0.1)) {
    Console::put(L"invalid offset\n");
  }

  // change the offset of the anchor
  //
  ancr_00.setOffset(0.6);
  if (!Integral::almostEqual(ancr_00.getOffset(), (float)0.6)) {
    Console::put(L"invalid offset\n");
  }
  if (!ancr_00.getAnchored()) {
    Console::put(L"invalid anchor flag\n");
  }

  // reset the offset of the anchor
  //   
  ancr_00.unsetOffset();
  if (ancr_00.getAnchored()) {
    Console::put(L"invalid anchor flag\n");
  }
  
  // verify that the unit has been set
  //    
  if (!ancr_00.getUnit().eq(unit_00)) {
    Console::put(L"invalid unit\n");
  }

  // change the unit of the anchor
  //      
  ancr_00.setUnit(unit_00);
  
  if (!ancr_00.getUnit().eq(unit_00)) {
    Console::put(L"invalid unit\n");
  }
  
  // exit gracefully
  //
  Integral::exit();
}
