exIndex.cc
RAVL, Recognition And Vision Library
SOURCE HOME PAGE CLASS LIST CONTENTS

// This file is part of RAVL, Recognition And Vision Library 
// Copyright (C) 2001, University of Surrey
// This code may be redistributed under the terms of the GNU Lesser
// General Public License (LGPL). See the lgpl.licence file for details or
// see http://www.gnu.org/copyleft/lesser.html
// file-header-ends-here
///////////////////////////////////////////////////////////////////
//! rcsid="$Id: exIndex.cc,v 1.4 2002/07/07 21:38:57 craftit Exp $"
//! lib=RavlCore
//! file="Ravl/Core/Base/exIndex.cc"

#include "Ravl/EntryPnt.hh"
#include "Ravl/Index.hh"
#include "Ravl/Stream.hh"

using namespace RavlN;

// Class AccessC enables to use class IndexC as normal index for 
// arrays of objects which do not conform IndexC interface. Therefore
// it is not necessary to call the member function IndexC::V().
template <class DataC>
struct AccessC
{
  AccessC(DataC * p)              :ptr(p) {}
  DataC & operator[](IndexC & i)  { return ptr[i.V()];}
  DataC * ptr;
};

int exIndex(int, char * [] )
{
  cout << "Index access example\n"
       << "====================\n";
  
  char buffer[] = "absdefghijklmnopqrstuvwxyz\n";
  AccessC<char> acc(buffer);
  UIntT mi = 2;  // a machine oriented index
  IndexC  i  = mi; // an index with a proper arithmetic operations
  cout << "Buffer[2]:    " << buffer[mi] << " == " << acc[i] << '\n'; 
  cout << "End of the example\n";
  return 0;
}

RAVL_ENTRY_POINT(exIndex)





Documentation by CxxDoc: Tue Aug 13 09:59:56 2002