~vbursian/research-assistant/intervers

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
////////////////////////////////////////////////////////////////////////////////
/*! @file FolderNode.h   A node of RANet Knowledgebase that can have attributes.
- Part of RANet - Research Assistant Net Library (based on ANSI C++).
- Copyright(C) 1994-2013, Viktor E. Bursian, St.Petersburg, Russia.
                          Viktor.Bursian@mail.ioffe.ru
*///////////////////////////////////////////////////////////////////////////////
#ifndef FolderNode_H
#define FolderNode_H
#include "Nodes.h"
#include "Attribute.h"
namespace RA {
//------------------------------------------------------------------------------

//ANNOUNCE_CLASS(sFolderNode)  //already predeclared in NodeLocation.h

//-------------------------------------------------------------- sFolderNode ---
/*! Simplest node of RANet Knowledgebase that can have attributes
    (also, a base class for all such nodes).

*/
class RANet_EXPORT  sFolderNode : public sNode
{
  STORABLE(sFolderNode)

  public://types
    enum                      tAttrListIOStatus {cToBeLoaded
                                                ,cSaved
                                                ,cRefreshed
                                                ,cChanged
                                                };

  public:
    virtual                   ~sFolderNode ();
    explicit                  sFolderNode (sString  docket =sString());
    virtual sString           Text (eTextFormat        /*F=Plain*/
                                   ,eTextDetalization  D=Casual
                                   ); //!< visual representation for user
    sString                   Docket ();
    virtual void              SetDocket (rcsString  new_docket);
    virtual bool              HasAttributes ();
    virtual bool              AttrsHaveToBeSaved () const;
    virtual bool              AttrsHaveToBeRefreshed () const;

  public://the following two members are used by for_each_* macros
         //they should never be used directly
    const std::list<sAttribute> &
                              Attributes () const
                                { return TheAttributes; }
    QMutex *                  AttrListMutexPtr ()
                                { return &AttrListMutex; }

  protected:
    virtual sNodePtr          GetAttr (sAttrName);
    virtual void              SetAttr (sAttribute);
    virtual sNodePtr          AscribeAttr (sAttribute);
//    virtual bool              AscribeModel (sNodePtr  ModelPtr);
//    virtual bool              DelAttr (rsAttributeFinger);
//                              //if successful, argument is shifted to the next
//                              //attribute; othervise it remains unchanged
    virtual void              DelAttr (sAttrName);
    virtual void              DelAttr (sNodePtr  value_ptr);
    virtual void              DeleteAllAttributes ();

  protected:
    virtual void              CopyFrom (psNode);

  private:
    void                      SetAttribute (sAttribute);
    void                      SetNamelessAttribute (sNodePtr);
    void                      SetNamedAttribute (sAttribute);
    sNodePtr                  AscribeAttribute (sAttribute);
    void                      AppendAttribute (sAttribute);
//    virtual void              RemoveAttribute (sAttribute);
    void                      MergeAttrList (std::list<sAttribute> &);
    virtual bool              AllocateAttributes ();
//    virtual bool              Strip ();

  private: //fields
    QMutex                    AttrListMutex;
    tAttrListIOStatus         AttrListIOStatus;
    sTime                     AttrListStatusTimeStamp;
    std::list<sAttribute>     TheAttributes;

    //!@todo{Net} Docket: rename to Tag; (?)new sence
    sString                   TheDocket;

  friend class sNet;
};

//------------------------------------------------------------------------------
} //namespace RA
#endif