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

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

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

  // declare Annotation objects
  //
  Anchor start_00;
  Anchor end_00;

  Anchor start_01;
  Anchor end_01;  

  String name_00(L"Annotation01");
  String type_00(L"W/Jane");  
  
  Annotation anno_00(name_00, &start_00, &end_00, type_00);

  // test the id method
  //
  if (!anno_00.getId().eq(name_00)) {
    Console::put(L"invalid name\n");
  }

  // test the anchor methods
  //
  if (anno_00.getStartAnchor() != &start_00) {
    Console::put(L"invalid start anchor\n");
  }
  if (anno_00.getEndAnchor() != &end_00) {
    Console::put(L"invalid end anchor\n");
  }

  anno_00.setStartAnchor(&start_01);
  anno_00.setEndAnchor(&end_01);
  
  if (anno_00.getStartAnchor() != &start_01) {
    Console::put(L"invalid start anchor\n");
  }
  if (anno_00.getEndAnchor() != &end_01) {
    Console::put(L"invalid end anchor\n");
  }

  // test the type method
  //
  if (!anno_00.getType().eq(type_00)) {
    Console::put(L"invalid type\n");
  }

  // declare some feature-value pairs
  //
  Vector<String> features;
  
  String feat_00(L"feature0");
  String value_00(L"value0");

  String feat_01(L"feature1");
  String value_01(L"value1");  
  
  // test the set feature methods
  //
  anno_00.setFeature(feat_00, value_00);
  anno_00.setFeature(feat_01, value_01);

  // test the exists feature methods
  //
  if (!anno_00.existsFeature(feat_00)) {
    Console::put(L"invalid feature\n");
  }

  // test the feature retrival methods
  //
  if (!anno_00.getFeature(feat_00).eq(value_00)) {
    Console::put(L"invalid feature/value\n");
  }
  
  // test the delete feature methods
  //
  if (!anno_00.deleteFeature(feat_00)) {
    Console::put(L"invalid feature\n");
  }
  if (anno_00.existsFeature(feat_00)) {
    Console::put(L"invalid feature\n");
  }

  // test the get feature names method
  //
  anno_00.getFeatureNames(features);

  if (features.length() != 1) {
    Console::put(L"invalid feature length\n");
  }
  if (!features.contains(&feat_01)) {
    Console::put(L"invalid feature/value\n");
  }
  
  // test the unset features method
  //
  if (!anno_00.unsetFeatures()) {
    Console::put(L"invalid feature/value\n");
  }
  if (!anno_00.getFeature(feat_01).eq(String::EMPTY)) {
    Console::put(L"invalid feature/value\n");
  }

  // exit gracefully
  //
  Integral::exit();
}
