home *** CD-ROM | disk | FTP | other *** search
/ Photo CD Demo 1 / Demo.bin / graphtal / name.h < prev    next >
C/C++ Source or Header  |  1992-10-28  |  2KB  |  73 lines

  1. /*
  2.  * Name.h - class definition for space efficient name storage.
  3.  *
  4.  * Copyright (C) 1992, Christoph Streit (streit@iam.unibe.ch)
  5.  * All rights reserved.
  6.  *
  7.  * This software may be freely copied, modified, and redistributed
  8.  * provided that this copyright notice is preserved on all copies.
  9.  *
  10.  * You may not distribute this software, in whole or in part, as part of
  11.  * any commercial product without the express consent of the authors.
  12.  *
  13.  * There is no warranty or other guarantee of fitness of this software
  14.  * for any purpose.  It is provided solely "as is".
  15.  *
  16.  */
  17.  
  18. #ifndef Name_H
  19. # define Name_H
  20.  
  21. #include <iostream.h>
  22. #include "rcString.h"
  23. #include "list.h"
  24.  
  25. //___________________________________________________________ Name
  26.  
  27. typedef rcString* rcStringPtr;
  28. declareList(rcStringList, rcStringPtr);
  29.  
  30. class Name
  31. {
  32. public:
  33.   Name(const char*);
  34.   Name(const rcString*);
  35.   Name(const Name&);
  36.  
  37.   const Name& operator=(const Name&);
  38.   int operator==(const Name&) const;
  39.   operator const char*() const;
  40.   long index() const;
  41.  
  42.   static long addname(const char*);
  43.   static long namesCount();
  44.   friend ostream& operator<<(ostream&, const Name&);
  45.  
  46. private:
  47.   static rcStringList* GlobalNameSpace;
  48.   long index_;
  49. };
  50.  
  51. typedef Name* NamePtr;
  52. declareList(NameList, NamePtr);
  53.  
  54. inline Name::Name(const Name& aName)
  55. : index_(aName.index_)
  56. {}
  57.  
  58. inline int Name::operator==(const Name& aName) const {
  59.   return (index_ == aName.index_);
  60. }
  61.  
  62. inline long Name::index() const  { 
  63.   return index_; 
  64. }
  65.  
  66. inline long Name::namesCount() { 
  67.   return GlobalNameSpace->count(); 
  68. }
  69.  
  70. #endif // Name_H
  71.  
  72.  
  73.