File: TheObjects.h

package info (click to toggle)
magnus 20060324-3
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 19,404 kB
  • ctags: 20,466
  • sloc: cpp: 130,118; ansic: 37,076; tcl: 10,970; perl: 1,109; makefile: 963; sh: 403; yacc: 372; csh: 57; awk: 33; asm: 10
file content (122 lines) | stat: -rw-r--r-- 4,401 bytes parent folder | download | duplicates (3)
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
// Copyright (C) 1995 The New York Group Theory Cooperative
// See magnus/doc/COPYRIGHT for the full notice.

// Contents: Declaration of class TheObjects
//
// Principal Author: Roger Needham
//
// Status: in progress
//
// Revision History:
//

#ifndef _THEOBJECTS_H_
#define _THEOBJECTS_H_


#include "Set.h"
#include "Associations.h"
#include "Chars.h"


//---------------------------------------------------------------------------//
//--------------------------- TheObjects ------------------------------------//
//---------------------------------------------------------------------------//

class TheObjects
{
public:

  /////////////////////////////////////////////////////////////////////////
  //                                                                     //
  // Constructors:                                                       //
  //                                                                     //
  /////////////////////////////////////////////////////////////////////////

  // No constructors for this static class.

  /////////////////////////////////////////////////////////////////////////
  //                                                                     //
  // Accessors:                                                          //
  //                                                                     //
  /////////////////////////////////////////////////////////////////////////

  static bool isRunning(OID oid);
  // True iff oid is the OID of a ComputationManager which is in
  // state RUNNING.

  static bool isStalled(OID oid);
  // Returns true when no running CM has any ARCs from oid.


  static SetOf<OID> remove(OID oid);
  // Removes and deletes the indicated SMObject, and all of its dependents.
  // A bad oid is quietly ignored, for messaging fault-tolerance.
  // Returns the dependency closure of oid, i.e., the objects which were
  // deleted.

  static SMObject* get(OID oid);
  // Returns the SMObject* with the given oid,
  // or 0 if there is no such object, for messaging fault-tolerance.
  // Used by class SessionManager and class Ctor.

  static SetOf<OID> dependencyClosure(OID oid);
  // A bad oid is quietly ignored, for messaging fault-tolerance.

  static Chars name(OID oid);
  // Returns name of the object with the given oid
 
private:

  /////////////////////////////////////////////////////////////////////////
  //                                                                     //
  // `Public' Members Touched by Friends:                                //
  //                                                                     //
  /////////////////////////////////////////////////////////////////////////

  friend class SMObject;
  friend class SessionManager;
  friend class Ctor;
  friend class UnboundedSupervisor;
  friend class ResourceManager;
  friend class ExtendToHomProblem; //@db temporary hack

  static OID reserveOid( );
  // Reserves a place in theObjects for a new SMObject, and returns the index.
  // Used by class SMObject to prepare for enrollment.

  static void enroll(SMObject* newObject);
  // Used by class SMObject.

  static void passControl( );
  // Passes control to a ComputationManager in a fair way.

  static void setName(OID oid, Chars name);
  // Changes name of an object

  /////////////////////////////////////////////////////////////////////////
  //                                                                     //
  // Private Members:                                                    //
  //                                                                     //
  /////////////////////////////////////////////////////////////////////////

  static void resize(int newLength);
  // A helper for expanding theObjects.

  /////////////////////////////////////////////////////////////////////////
  //                                                                     //
  // Data Members:                                                       //
  //                                                                     //
  /////////////////////////////////////////////////////////////////////////

  static const int minimumLength = 16;
  static int theObjectsLength;
  static SMObject** theObjects;

  static int CMToGetControl;
  
  // keeps a copy of the names of the objects for SM use
  static AssociationsOf<OID,Chars>* theNames; 
};

#endif