~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
93
94
95
////////////////////////////////////////////////////////////////////////////////
/*! @file Record.h   Class sRecord.
- Part of RANet - Research Assistant Net Library (based on ANSI C++).
- Copyright(C) 2010, Viktor E. Bursian, St.Petersburg, Russia.
                     Viktor.Bursian@mail.ioffe.ru
*///////////////////////////////////////////////////////////////////////////////
#ifndef Record_H
#define Record_H
#include "FolderNode.h"
#include "Time.h"
namespace RA {
//------------------------------------------------------------------------------

ANNOUNCE_ABSTRACT_CLASS(sRecord)

//------------------------------------------------------------------ sRecord ---

class RANet_EXPORT  sRecord : public sFolderNode
{
  STORABLE(sRecord)
  public:
    typedef int               fNewRecordNumber (rcsTime);

  public: //static const
    static const char         cDateSeparator;
    static const char         cNumberSeparator;

  public: //static field
    static fNewRecordNumber * NewRecordNumber;
    static sPtr<sFolderNode>  RecordNumberingData;
    static sPtr<sFolderNode>  ChronologicalStorage;

  public: //static
    static bool               ParseIdentifier (rcsString  src
                                              ,int &      cursor
                                              ,int &      year
                                              ,int &      month
                                              ,int &      day
                                              ,int &      number);
    static sPtr<sRecord>      FindRecord (integer  year
                                         ,integer  month
                                         ,integer  day
                                         ,integer  number);

  public:
    explicit                  sRecord ();
  protected:
    explicit                  sRecord (int  record_no);

  public:
    virtual sString           Text (eTextFormat        /*F=Plain*/
                                   ,eTextDetalization  /*D=Casual*/
                                   ); //!< visual representation for user
    virtual sString           FullIdentifier () const;
    virtual sString           ShortIdentifier () const;
//    virtual bool              IdentifierMatches (rcsString) const;
    sTime                     StartTime () const
                                { return TheStartTime; }
    sTime                     FinishTime () const
                                { return TheStartTime+TheDuration; }
    real                      Duration () const //!< in seconds
                                { return TheDuration; }
    int                       RecordNo () const
                                { return TheRecordNo; }
    void                      SetStartTime (sTime  T)
                                { TheStartTime=T; }
    void                      SetStartTime ()
                                { TheStartTime=sTime(); }
    void                      SetFinishTime (sTime  T)
                                { TheDuration=T-TheStartTime; }
    void                      SetFinishTime ()
                                { TheDuration=sTime()-TheStartTime; }
    void                      SetDuration (real  Dur)
                                { TheDuration=Dur; }
    void                      SetRecordNo (int  record_no)
                                { TheRecordNo=record_no; }
    sPtr<sFolderNode>         AllocateRecord ();
    void                      AllocateHistorically (sPtr<sFolderNode>  in_here);
    void                      DisregardRecord (sString  Reason);

  protected:
    virtual void              CopyFrom (psNode);

  private:
    static int                Default_NewRecordNumber (rcsTime);

  private: //fields
    sTime                     TheStartTime;
    real                      TheDuration; //!< in seconds
    int                       TheRecordNo;
};

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