~d-nelson/research-assistant/nextDNK

« back to all changes in this revision

Viewing changes to RANet/AttrNames.h

  • Committer: Viktor Bursian
  • Date: 2013-06-06 13:42:39 UTC
  • Revision ID: vbursian@gmail.com-20130606134239-bx5ks8sg3y9oqckz
Tags: version_0.2.0
first usable version 0.2.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
////////////////////////////////////////////////////////////////////////////////
 
2
/*! @file AttrNames.h   Различные виды имён атрибутов.
 
3
- Part of RANet - Research Assistant Net Library (based on ANSI C++).
 
4
- Copyright(C) 1999-2010, Viktor E. Bursian, St.Petersburg, Russia.
 
5
                     Viktor.Bursian@mail.ioffe.ru
 
6
*///////////////////////////////////////////////////////////////////////////////
 
7
#ifndef AttrNames_H
 
8
#define AttrNames_H
 
9
#include "Storable.h"
 
10
namespace RA {
 
11
//------------------------------------------------------------------------------
 
12
 
 
13
ANNOUNCE_CLASS(sAtom)
 
14
ANNOUNCE_CLASS(sAttributeName)
 
15
 
 
16
typedef sString               tAttrString;
 
17
typedef tAttrString &         rtAttrString;
 
18
typedef const tAttrString &   rctAttrString;
 
19
 
 
20
 
 
21
 
 
22
//------------------------------------------------------------------------------
 
23
 
 
24
class RANet_EXPORT  sAtom
 
25
{
 
26
  public:
 
27
                              sAtom (literal identification);
 
28
 
 
29
  private:
 
30
    unsigned int              Id;
 
31
    literal                   VisualId;
 
32
 
 
33
  private: //static
 
34
    static unsigned int       Counter;
 
35
    //! @todo{atoms} static map or set to prevent dublicates
 
36
    //static std::string               FindVisualId (unsigned int);
 
37
    //static unsigned int              FindId (std::string);
 
38
  friend class sAttributeName;
 
39
};
 
40
 
 
41
//------------------------------------------------------------------------------
 
42
 
 
43
class RANet_EXPORT  sAttributeName
 
44
{
 
45
  #ifdef RANET_DEBUG
 
46
  public:
 
47
    static unsigned int       Counter;
 
48
  #endif
 
49
  public: //types
 
50
    enum                      eType
 
51
                                {NamelessAttr,NumericAttr
 
52
                                ,AtomicAttr,SymbolicAttr};
 
53
 
 
54
  public:
 
55
                              ~sAttributeName ()
 
56
                                { IF_DEBUG(--Counter;) };
 
57
                              sAttributeName ()
 
58
                                  :T(NamelessAttr)
 
59
                                { IF_DEBUG(++Counter;) };
 
60
                              sAttributeName (rcsAtom      atom)
 
61
                                  :T(AtomicAttr),AtomId(atom.Id)
 
62
                                { IF_DEBUG(++Counter;) };
 
63
                              sAttributeName (unsigned int number)
 
64
                                  :T(NumericAttr),Number(number)
 
65
                                { IF_DEBUG(++Counter;) };
 
66
                              sAttributeName (rctAttrString  symbolic_name);
 
67
                              sAttributeName (literal  symbolic_name);
 
68
    eType                     Type () const
 
69
                                { return T; };
 
70
    virtual sString           Text () const; // visual representation for user
 
71
    virtual sString           TextWithoutTypeIndication () const;
 
72
                              operator unsigned int () const
 
73
                                { return Number; };
 
74
    bool                      operator == (rcsAttributeName) const;
 
75
    bool                      operator == (const unsigned int &) const;
 
76
    bool                      operator == (rctAttrString) const;
 
77
    bool                      operator == (literal) const;
 
78
                              sAttributeName (rsObjectStream);
 
79
    virtual void              Store (rsObjectStream);
 
80
                              sAttributeName (rcsAttributeName);
 
81
    virtual rsAttributeName   operator = (rcsAttributeName);
 
82
 
 
83
  private: //fields
 
84
    eType                     T;
 
85
    unsigned int              AtomId;
 
86
    unsigned int              Number;
 
87
    tAttrString               SymbolicName;
 
88
};
 
89
 
 
90
//------------------------------------------------------------------------------
 
91
}; //namespace RA
 
92
#endif