SPEEDES 0.4
Index
Metric Summary for SPEEDES 0.4
Total number of classes | 26 |
Total number of statements | 562 |
Total number of free standing functions | 23 |
Average statements per class | 20 |
Average McCabe complexity per class | 15 |
Average number of public member functions per class | 22 |
Average number of protected member functions per class | 0 |
Average number of parameters per function | 0.8 |
Average number of statements per function | 1.5 |
Percent of functions documented | 83% |
Metric Summary for SPEEDES Fundamentals
Total number of classes | 12 | 46% of total |
Total number of statements | 407 | 72% of total |
Total number of free standing functions | 11 | 47% of total |
Average statements per class | 31 | 58% from average |
Average McCabe complexity per class | 23 | 55% from average |
Average number of public member functions per class | 27 | 25% from average |
Average number of protected member functions per class | 0 | 117% from average |
Average number of parameters per function | 0.9 | 9% from average |
Average number of statements per function | 1.5 | 5% from average |
Percent of functions documented | 77% | -7% from average |
Metric Summary for EVENTS--------------------------------------------------------------------------+
Total number of classes | 1 | 3% of total |
Total number of statements | 110 | 19% of total |
Total number of free standing functions | 4 | 17% of total |
Average statements per class | 81 | 315% from average |
Average McCabe complexity per class | 79 | 425% from average |
Average number of public member functions per class | 120 | 447% from average |
Average number of protected member functions per class | 0 | -100% from average |
Average number of parameters per function | 0.9 | 12% from average |
Average number of statements per function | 1.3 | -8% from average |
Percent of functions documented | 99% | 20% from average |
Class Metrics
Class | Public Members | Statements | McCabe Complexity |
C_EVENT | 120 | 81 | 79 |
#include "event.H"
Class: C_EVENT
Summary: A generic simulation event
Description: This is the fundamental active building block in SPEEDES
applications that acts on C_SIMOBJs. It is also the way SPEEDES
passes simulated time. C_EVENTs are discrete events are designed
to act on a single class (type) of simulation object, ie, a
particular descendent of C_SIMOBJ. Events are generally also
responsible for scheduling other events. To achieve maximum
reuse, C_EVENTs should provide all of the actions and
associations between C_SIMOBJs.
Public Interface
-
-
-
INTERNAL METHOD
-
Method: WriteLookaheadfile
Summary: Write to the lookahead file, if enabled
Description:
Return: None
- t2
- Lookahead time.
- ty2
- Second object EVENT_TYPE.
- ot2
- Second object OBJECT_TYPE.
- id2
- Second object LOCAL_ID.
- nd
- Second object NODE.
-
INTERNAL METHOD
-
INTERNAL METHOD
-
Method: cancel
Summary: Cancel the event specified by a C_CANCEL_HANDLE
Description: The event to be cancelled must have been scheduled with the
cancel handle used here (C_CANCEL_HANDLE), and the event to
cancel must be in the simulated time future.
Return: None.
- ch
- IN: the cancel handle (C_CANCEL_HANDLE) of the event to cancel, which was the first argument in that event's schedule () call.
-
INTERNAL METHOD
-
INTERNAL METHOD
- n_roll
- Number of rollbacks.
-
INTERNAL METHOD
-
INTERNAL METHOD
-
Virtual Method: cleanup
Summary: User-written code called in the event destructor
Description:
Return: None
-
INTERNAL METHOD
-
INTERNAL METHOD
-
Virtual Method: commit
Summary: The part of the user process code that is run after the event is
committed (same as perm_process())
Description: The user should override this method whenever they want code to
be guaranteed not to rollback. This is achieved by the SPEEDES
framework by calling this method after the event has been
committed (ie, after it has passed global virtual time and thus
won't ever again rollback). This method is overridden whenever
the user needs to call code outside of the SPEEDES framework and
calling it more than once is undesired (such as calling screen
graphics). An alternative to using commit() is to extend the
SPEEDES framework with rollbackable items that can thus be used
within the process() method.
Return: None
-
Overloaded Method: create_object
Summary: Schedule for dynamically creating a simulation object (C_SIMOBJ)
Description: This is simply a schedule call for a CREATE event. Like all
schedule calls, it returns the associated message.
Return: the message for dynamically created simulation object (C_SIMOBJ)
- time
- IN: simulated time to create the object.
- object_type
- IN: type of object to create.
- object_node
- IN: node on which to create the object.
-
Overloaded Method: create_object
Summary: Schedule for dynamically creating a simulation object (C_SIMOBJ)
Description: This is simply a schedule call for a CREATE event. Like all
schedule calls, it returns the associated message.
Return: the message for dynamically created simulation object (C_SIMOBJ)
- ch
- Cancel handle (see schedule method).
- time
- IN: simulated time to create the object.
- object_type
- IN: type of object to create.
- object_node
- IN: node on which to create the object.
-
void* create_object |
(
SIMTIME& time
,
int object_type
,
int object_node
,
int mess_size
,
char*& buf
) ; |
Overloaded Method: create_object
Summary: Schedule for dynamically creating a simulation object (C_SIMOBJ)
Description: This is simply a schedule call for a CREATE event. Like all
schedule calls, it returns the associated message.
Return: the message for dynamically created simulation object (C_SIMOBJ)
- time
- IN: simulated time to create the object.
- object_type
- IN: type of object to create.
- object_node
- IN: node on which to create the object.
- mess_size
- IN: (OPTIONAL) number of bytes of the variable-length part of the event message.
- buf
- IN: (USED IF AND ONLY IF "mess_size" IS USED) the variable-length part of the event message.
-
void* create_object |
(
void* ch
,
SIMTIME& time
,
int object_type
,
int object_node
,
int mess_size
,
char*& buf
) ; |
Overloaded Method: create_object
Summary: Schedule for dynamically creating a simulation object (C_SIMOBJ)
Description: This is simply a schedule call for a CREATE event. Like all
schedule calls, it returns the associated message.
Return: the message for dynamically created simulation object (C_SIMOBJ)
- ch
- Cancel handle (see schedule method).
- time
- IN: simulated time to create the object.
- object_type
- IN: type of object to create.
- object_node
- IN: node on which to create the object.
- mess_size
- IN: (OPTIONAL) number of bytes of the variable-length part of the event message.
- buf
- IN: (USED IF AND ONLY IF "mess_size" IS USED) the variable-length part of the event message.
-
INTERNAL METHOD
-
Overloaded Method: destroy_object
Summary: Schedule for dynamically destroying (deleting) a simulation object
(C_SIMOBJ)
Description: This is simply a schedule call for a DESTROY event. Like all
schedule calls, it returns the associated message.
Return: the message for dynamically destroyed simulation object (C_SIMOBJ)
- time
- IN: simulated time to destroy the object.
- object_type
- IN: type of object to destroy.
- object_id
- IN: the LOCAL_ID of the object to destroy.
- object_node
- IN: node on which to destroy the object.
-
Overloaded Method: destroy object
Summary: Schedule for dynamically destroying (deleting) a simulation object
(C_SIMOBJ)
Description: This is simply a schedule call for a DESTROY event. Like all
schedule calls, it returns the associated message.
Return: the message for dynamically destroyed simulation object (C_SIMOBJ)
- ch
- Cancel handle (see schedule method).
- time
- IN: simulated time to destroy the object.
- object_type
- IN: type of object to destroy.
- object_id
- IN: the LOCAL_ID of the object to destroy.
- object_node
- IN: node on which to destroy the object.
-
Method: event_type
Summary: Get the enumerated ID for an event type, specified by the event
type's string name
Description:
Return: the enumerated ID for an event type
-
Virtual Method: exchange
Summary: This is for the user to write exchange code for fast rollbacks.
Description: This is usually not required, since rollbackable items in the
process virtual method essentially undergo exchanges
automatically. But if rollbackable items are not available for
certain state data, this method allows the user to write
low-level code to exchange a value with a saved previous
value. The SPEEDES framework calls this method whenever
performing a rollback.
Return: None
-
Method: get_CANCEL
Summary: Get the ID (ie, the enumerated type) of the CANCEL event
Description: This is used for scheduling CANCEL events, which are events that
cancel other non-committed events on the event queue
Return: the ID (ie, the enumerated type) of the CANCEL event
-
Method: get_CREATE
Summary: Get the ID (ie, the enumerated type) of the CREATE event
Description: This is used for scheduling CREATE events, which are events that
dynamically create simulation objects (C_SIMOBJs)
Return: the ID (ie, the enumerated type) of the CREATE event
-
Method: get_DESTROY
Summary: Get the ID (ie, the enumerated type) of the DESTROY event
Description: This is used for scheduling DESTROY events, which are events that
dynamically destroy (delete) simulation objects (C_SIMOBJs)
Return: the ID (ie, the enumerated type) of the DESTROY event
-
Method: get_EVENT_HANDLER_EVENT
Summary: Get the ID (ie, the enumerated type) of the EVENT_HANDLER_EVENT
event
Description: This is used internally by SPEEDES to get the id of the event
handler event
Return: the ID (ie, the enumerated type) of the DESTROY event
-
Method: get_EVENT_TYPE
Summary: Get the ID (or enumerated type) of the type of this event
Description: A unique EVENT_TYPE is required for each C_EVENT class, and is
found in event_types.C
Return: the OBJECT_TYPE, ie, the ID of the type of this simulation type
-
Method: get_GLOBAL_ID
Summary: Get the unique ID, simulaiton-wide, of the object associated with
this event. GLOBAL_ID generated automatically, but can be overridden
by the user.
Description:
Return: the unique ID of this simulation object
-
INTERNAL METHOD
-
Method: get_LOCAL_ID
Summary: Get the ID of the simulation object associated with this event
Description: Each object manager has its own set of C_SIMOBJs, each with
their own LOCAL_ID. Thus LOCAL_ID only needs to be unique for a
given object manager (C_OBJMAN), not unique to a given node or
to a given simulation
Return: the ID of this simulation object
-
Method: get_MESSAGE
Summary: Get the message used to enact this event
Description: This is a fundamental method for C_EVENT, since events are
enacted by a message, and that message often contains
information intended to be extracted by its effected event. Use
this method get and then read the contents of the message.
Return: the message used to enact this event
-
Method: get_NODE
Summary: Get the node (process number on local machine) that this C_SIMOBJ is
instantialted on.
Description:
Return: the node (process number on local machine) that this C_SIMOBJ
is instantialted on.
-
Method: get_N_NODES
Summary: Get the total number of nodes (process number on local machine) in
the entire simulation (including all other machines' process)
Description:
Return: total number of nodes
-
Method: get_OBJECT_TYPE
Summary: Get the ID (or enumerated type) of the type of the simulation
object associated with this event
Description: A unique OBJECT_TYPE is required for each C_SIMOBJ class. Each
C_SIMOBJ class is managed by one instantiation of
C_OBJMAN. Thus, the OBJECT_TYPE also uniquely defines the type
of C_SIMOBJ that each instantiation of C_OBJMAN manages. Each
node has a single instantiation of C_OBJECTS, which in turn
manages a list of C_OBJMANs. C_OBJECTS refers to each C_OBJMAN
by the OBJECT_TYPE it manages.
Return: the OBJECT_TYPE, ie, the ID of the type of this simulation type
-
Method: get_RANDOM
Summary: Get the random number generator. There is exactly one C_RANDOM
object per node, set automatically by the framework.
Description: see C_RANDOM
Return: the random number generator
-
Method: get_SIMOBJ
Summary: Get the simulation object (C_SIMOBJ) associated with this event
Description: This is a fundamental method for C_EVENT, since events are
designed to act upon one type of simulation object, ie one class
that inherits from C_SIMOBJ. Use this method to read and write
to the simulation object on which the event is acting.
Return: the simulation object associated with this event
-
INTERNAL METHOD
-
INTERNAL METHOD
-
INTERNAL METHOD
-
INTERNAL METHOD
-
INTERNAL METHOD
-
INTERNAL METHOD
-
INTERNAL METHOD
-
INTERNAL METHOD
-
Method: get_manager
Summary: Get the object manager for another simulation object, specified by
its OBJECT_TYPE
Description:
Return: an object manager, casted to (void *)
- om
- IN: OBJECT_TYPE of the desired object manager.
-
INTERNAL METHOD
-
INTERNAL METHOD
-
INTERNAL METHOD
-
INTERNAL METHOD
-
INTERNAL METHOD
-
INTERNAL METHOD
-
INTERNAL METHOD
-
INTERNAL METHOD
-
INTERNAL METHOD
- q1nd
- OUT: the messages coming in.
-
virtual void init |
(
C_HEADER*
) ; |
Virtual Method: init
Summary: Initialize this event
Description: This is for the user to write code that gets executed in this
event's constructor. That is, code in this method will not occur
in the process virtual method phase, and thus will not get
rolled back.
Return: None
-
- The framework passes in the message for the event here, and its use is optional.
-
INTERNAL METHOD
-
INTERNAL METHOD
-
Virtual Method: lazy
Summary: User code written to determine, each time this event rolls back,
whether to roll forward (and thus avoid the overhead of sending
antimessages and reprocessing) or to undergo the normal rollback
operations.
Description: Often when an event gets rolled back and reproccessed, the
results of the simulation are the same (or nearly the same) as
if the framework didn't roll it back at all even though it was
processed out of simulated time order. This is user code to
determine whether this event should send out antimessages when
it gets rolled back (like a regular rollback) or whether, after
rolling back, tests show that nothing critical would change by
sending out antimessages and thus it can simply roll forward
back to where it was before it got rolled back.
Return: flag for whether the lazy test passed (non-zero = pass). If it
passes, and if lazy cancellation is enabled, this event is rolled
forward without sending out antimessages. If it fails, it is treated
just like any other rollback.
-
INTERNAL METHOD
-
INTERNAL METHOD
-
Method: memory_print
Summary: print out event free list memory statistics
Description:
Return: None
-
Method: object_type
Summary: Retrieves a simulation object's OBJECT_TYPE (see set_OBJECT_TYPE)
based on its string NAME
Description:
Return: the object type of this simulation object
-
Method: open_Lookaheadfile
Summary: Open a file into which to output lookahead information
Description:
Return: None
-
Method: open_tracefile
Summary: Open a file into which to output trace information (see trace())
Description:
Return: None
- filename
- Filename for trace output.
-
INTERNAL METHOD
-
Virtual Method: perm_process
Summary: The part of the user process code that is run after the event is
committed (same as commit())
Description: The user should override this method whenever they want code to
be guaranteed not to rollback. This is achieved by the SPEEDES
framework by calling this method after the event has been
committed (ie, after it has passed global virtual time and thus
won't ever again rollback). This method is overridden whenever
the user needs to call code outside of the SPEEDES framework and
calling it more than once is undesired (such as calling screen
graphics). An alternative to using commit() is to extend the
SPEEDES framework with rollbackable items that can thus be used
within the process() method.
Return: None
-
INTERNAL METHOD
-
Method: print_event_memory
Summary: print out event free list memory statistics
Description:
Return: None
-
Virtual Method: process
Summary: The main process user code block (same as temp_process())
Description: The user overrides this method for essentially every C_EVENT.
That is because it is the place where the body of user code is
written for the event. It is the only virtual method wherein
rollbackable operations (such as using STATE variables, etc.)
are permitted. State information that is not rollbackable should
not be used in this method, since this method is run more than
once whenever it is rolled back and reprocessed. Also, calls to
outside of the SPEEDES framework should not go here for the same
reason, and should instead occur in the commit virtual function.
Return: None
-
Method: reset_WriteLookahead
Summary: Disable write lookahead
Description:
Return: None
-
INTERNAL METHOD
-
Method: reset_lazy
Summary: Disable lazy cancellation
Description:
Return: None
-
INTERNAL METHOD
-
INTERNAL METHOD
-
Method: reset_trace
Summary: Disable tracing this event
Description:
Return: None
-
INTERNAL METHOD
-
INTERNAL METHOD
-
INTERNAL METHOD
-
void* schedule |
(
const SIMTIME& time
,
int event_type
,
int object_type
,
int object_id
,
int object_node
) ; |
Overloaded Method: schedule
Summary: Schedule an event at the present or a future simulated time for any
simulation object (C_SIMOBJ) in the simulation
Description: This is a fundamental method for C_EVENT, since events are
generally responsible for scheduling future events. The message
for this event schedule is returned (*C_HEADER), and should be
subsequently filled in. This is OK, since the message isn't sent
until after the event user code (the process() virtual method)
completes.
Return: the message for this scheduled event (*C_HEADER)
- time
- IN: simulated time.
- event_type
- IN: enumerated or integer type of event to schedule.
- object_type
- IN: enumerated or integer type of object for which to schedule the event (must be the one type of object required for the event_type).
- object_id
- IN: the LOCAL_ID of the object for which to schedule the event.
- object_node
- IN: the NODE of the object for which to schedule the event.
-
void* schedule |
(
void* ch
,
const SIMTIME& time
,
int event_type
,
int object_type
,
int object_id
,
int object_node
) ; |
Overloaded Method: schedule
Summary: Schedule a cancelable event at the present or a future simulated
time for any simulation object (C_SIMOBJ) in the simulation
Description: This is a fundamental method for C_EVENT, since events are
generally responsible for scheduling future events. The message
for this event schedule is returned (inherited from C_HEADER),
and should be subsequently filled in. This is OK, since the
message isn't sent until after the event user code (the
process() virtual method) completes. The cancel handle (first
argument) simply must be an uninitialized object (ie, the user
need only create it, not fill it in) of type C_CANCEL_HANDLE (or
equivalently, C_ANTIMESS, which is what it is typedef'd
with). This function returns the handle filled-in with all of
the information to use this handle later in the cancel () call,
to later cancel the event now being scheduled. The cancel ()
call, if later called by the user, will cancel the event now
being scheduled by scheduling a CANCEL event. When calling
cancel (), the event to cancel must be in the simulated time
future.
Return: The message for this scheduled event (inherited from C_HEADER)
- ch
- INOUT: cancel handle.
- time
- IN: simulated time.
- event_type
- IN: enumerated or integer type of event to schedule.
- object_type
- IN: enumerated or integer type of object for which to schedule the event (must be the one type of object required for the event_type).
- object_id
- IN: the LOCAL_ID of the object for which to schedule the event.
- object_node
- IN: the NODE of the object for which to schedule the event.
-
void* schedule |
(
const SIMTIME& time
,
int event_type
,
int object_type
,
int object_id
,
int object_node
,
int mess_size
,
char*& buf
) ; |
Overloaded Method: schedule
Summary: Schedule an event at the present or a future simulated time for any
simulation object (C_SIMOBJ) in the simulation. This version of
schedule () allows the event's message to contain a variable-length
character buffer as well as the variables contained in the inherited
C_HEADER.
Description: This is a fundamental method for C_EVENT, since events are
generally responsible for scheduling future events. The message
for this event schedule is returned (*C_HEADER), and should be
subsequently filled in. This is OK, since the message isn't sent
until after the event user code (the process() virtual method)
completes.
Return: the message for this scheduled event (*C_HEADER)
- time
- IN: simulated time.
- event_type
- IN: enumerated or integer type of event to schedule.
- object_type
- IN: enumerated or integer type of object for which to schedule the event (must be the one type of object required for the event_type).
- object_id
- IN: the LOCAL_ID of the object for which to schedule the event.
- object_node
- IN: the NODE of the object for which to schedule the event.
- mess_size
- IN: (OPTIONAL) number of bytes of the variable-length part of the event message.
- buf
- IN: (USED IF AND ONLY IF "size" IS USED) the variable-length part of the event message.
-
void* schedule |
(
void* ch
,
const SIMTIME& time
,
int event_type
,
int object_type
,
int object_id
,
int object_node
,
int mess_size
,
char*& buf
) ; |
Overloaded Method: schedule
Summary: Schedule a cancelable event at the present or a future simulated
time for any simulation object (C_SIMOBJ) in the simulation. This
version of schedule () allows the event's message to contain a
variable-length character buffer as well as the variables contained
in the inherited C_HEADER.
Description: This is a fundamental method for C_EVENT, since events are
generally responsible for scheduling future events. The message
for this event schedule is returned (inherited from C_HEADER),
and should be subsequently filled in. This is OK, since the
message isn't sent until after the event user code (the
process() virtual method) completes. The cancel handle (first
argument) simply must be an uninitialized object (ie, the user
need only create it, not fill it in) of type C_CANCEL_HANDLE (or
equivalently, C_ANTIMESS, which is what it is typedef'd
with). This function returns the handle filled-in with all of
the information to use this handle later in the cancel () call,
to later cancel the event now being scheduled. The cancel ()
call, if later called by the user, will cancel the event now
being scheduled by scheduling a CANCEL event. When calling
cancel (), the event to cancel must be in the simulated time
future.
Return: The message for this scheduled event (inherited from C_HEADER)
- ch
- IN: cancel handle.
- time
- IN: simulated time.
- event_type
- IN: enumerated or integer type of event to schedule.
- object_type
- IN: enumerated or integer type of object for which to schedule the event (must be the one type of object required for the event_type).
- object_id
- IN: the LOCAL_ID of the object for which to schedule the event.
- object_node
- IN: the NODE of the object for which to schedule the event.
- mess_size
- IN: (OPTIONAL) number of bytes of the variable-length part of the event message.
- buf
- IN: (USED IF AND ONLY IF "size" IS USED) the variable-length part of the event message.
-
INTERNAL METHOD
- q1nd
- IN: the messages to send out.
-
INTERNAL METHOD
-
INTERNAL METHOD
-
INTERNAL METHOD
-
INTERNAL METHOD
-
INTERNAL METHOD
-
INTERNAL METHOD
-
INTERNAL METHOD
-
INTERNAL METHOD
-
INTERNAL METHOD
-
INTERNAL METHOD
-
INTERNAL METHOD
-
INTERNAL METHOD
-
INTERNAL METHOD
-
INTERNAL METHOD
-
Method: set_WriteLookahead
Summary: Enable write lookahead
Description:
Return: None
-
INTERNAL METHOD
-
INTERNAL METHOD
-
INTERNAL METHOD
-
INTERNAL METHOD
-
Method: set_lazy
Summary: Enable lazy cancellation
Description:
Return: None
-
INTERNAL METHOD
-
INTERNAL METHOD
-
INTERNAL METHOD
-
INTERNAL METHOD
-
INTERNAL METHOD
-
Method: set_trace
Summary: Enable tracing this event
Description:
Return: None
-
INTERNAL METHOD
-
INTERNAL METHOD
-
INTERNAL METHOD
- twait
- Amount of time to add to the desired point in time to wait.
-
Virtual Method: temp_process
Summary: The main process user code block (same as process())
Description: This method is essentially always overridden for every C_EVENT.
That is because it is the place where the body of user code is
written for the event. It is the only virtual method wherein
rollbackable operations (such as using STATE variables, etc.)
are permitted. State information that is not rollbackable should
not be used in this method, since this method is run more than
once whenever it is rolled back and reprocessed. Also, calls to
outside of the SPEEDES framework should not go here for the same
reason, and should instead occur in the commit virtual function.
Return: None
-
Method: trace
Summary: Trace this event
Description: Provide statistics about this event to a trace file during run
time
Return: None
-
INTERNAL METHOD
-
INTERNAL METHOD
-
INTERNAL METHOD
-
INTERNAL METHOD
-
INTERNAL METHOD
Protected Interface
Protected Data
static int CANCEL;
- Cancel event type id.
static int CREATE;
- Create object event type id.
static int DESTROY;
- Destroy object event type id.
static int EVENT_HANDLER_EVENT;
- Event handler event type id.
int EVENT_TYPE;
- Event type.
int GLOBAL_ID;
- Global id for simobj.
static C_HOST_USER* HOST_USER;
- Host user object.
C_HEADER* MESSAGE;
- Pointer to event message.
static int NODE;
- Node.
static int N_NODES;
- Number of nodes.
int OBJECT_TYPE;
- Object type.
static C_RANDOM* RANDOM;
- Random number generator.
C_SIMOBJ* SIMOBJ;
- Generic object for all objects.
static C_RBQ* rbq;
- Roll back queue manager.
Private Interface
Private Data
static int EnableLazy;
- Lazy cancellation enabled flag.
static FILE* LookaheadFP;
- File pointer for lookahead file.
static char* Lookaheadfile;
- Name of lookahead file.
static int WriteLookahead;
- Write lookahead file (1=on, 0=off).
int cancel_id;
- Cancel event id.
C_DBL_ITEM dbl_item;
- Processed event item.
static C_DBL_QUEUE* dbl_qproc;
- Queue of processed events.
int event_canceled;
- Event has canceled flag.
C_LPTR evtptr;
- Optimistic event object.
static C_EVENT_TYPES* evtype;
- Event and message memory manager.
static int first_cancel;
- Flag for first canceled event.
int free_flag;
- Flag set only by free list management.
static int gencid;
- Generated cancel id.
int lazy_flag;
- Flag for lazy cancellation.
int lazy_proc;
- Flag for lazy processed.
static C_OBJECTS* objects;
- Object manager.
C_OBJEVT objevt;
- Object event status and link.
static int one_node_flag;
- One node flag.
C_QUEUE optevts;
- Queue of optimistically generated events.
C_QUEUE qanti;
- Queue of outgoing antimessages.
C_QUEUE qmessout;
- Queue of outgoing messages.
C_QUEUE qroll_backs;
- Queue of roll backs.
int rbid;
- Roll back unique id.
static double spin_clock;
- Clocked spin time.
static double spin_time;
- Desired spin time.
double tmin;
- Minimum time of a generated message.
static FILE* traceFP;
- File pointer for trace file.
static char* tracefile;
- Name of trace file.
static int traceflag;
- Trace flag (1 means on, 0 means off).
int valid;
- Valid event flag.
void CancelEvent(C_CANCEL_HANDLE* cancelHandle
) ;
|
Function: CancelEvent
Summary: Cancels an event (or event handler) that was previously scheduled.
Description: This function may be called from anywhere in a SPEEDES
application to retract an event that was previously scheduled.
Return: void
|
- cancelHandle
- IN: Cancel handle.
|
C_CANCEL_HANDLE ReScheduleEvent(const SIMTIME& time
,
C_HEADER* header = NULL
,
char* data = NULL
,
int dataBytes = 0
) ;
|
Function: ReScheduleEvent
Summary: Re-schedules the same event to be processed for the same simobj at
a future time.
Description: This function can be called from anywhere within SPEEDES to
reschedule the same event for the same simobj for processing
at a later time.
Return: A cancel handle for the event which can be later used to retract
the event before it is processed. Applications are not required to
use this returned value.
|
- time
- IN: Logical time.
- header
- IN: Optional message for scheduling the event.
- data
- IN: Variable length data that gets passed with the event (optional).
- dataBytes
- IN: Number of bytes for variable length data.
|
C_CANCEL_HANDLE ScheduleEvent(const SIMTIME& time
,
int eventType
,
int simobjType
,
int simobjLocalId
,
int simobjNode
,
C_HEADER* header = NULL
,
char* data = NULL
,
int dataBytes = 0
) ;
|
Function: ScheduleEvent
Summary: Schedules an event to be processed for a simobj at a specified.
time. Events must never be scheduled in the past of the current
event.
Description: This function can be called from anywhere within SPEEDES to
schedule an event. An event must have a time tag, event type
simulation object type, simulation object local Id, and node
number to uniquely identify the event and the simobj that it
acts on. Optional arguments are the message header (users must
set specified data members before making the schedule call), and
a variable data buffer followed by the number of bytes. If the
variable data buffer is not provided, the SPEEDES internal
free list mechanisms are used to reduce overheads.
Return: A cancel handle for the event which can be later used to retract
the event before it is processed. Applications are not required to
use this returned value.
|
- time
- IN: Logical time.
- eventType
- IN: Event type Id.
- simobjType
- IN: Simulation object type.
- simobjLocalId
- IN: Simulation object local Id.
- simobjNode
- IN: Node that the simulation object is on.
- header
- IN: Optional message for scheduling the event.
- data
- IN: Variable length data that gets passed with the event (optional).
- dataBytes
- IN: Number of bytes for variable length data.
|
C_CANCEL_HANDLE ScheduleEventHandler(const SIMTIME& time
,
char* eventName
,
int simobjType
,
int simobjLocalId
,
int simobjNode
,
char* data
,
int dataBytes
) ;
|
Overloaded Function: ScheduleEventHandler
Summary: Schedule an event handler for the present or future time for any
simulation object (C_SIMOBJ) in the simulation. The data that
is passed in gets delivered to the event handler when it is
processed. The cancel handle is returned to the application and can
later be used to retract the event.
Description: This method may be called from anywhere in a SPEEDES
application and schedules an event handler for any simulation
object. The eventName is the name of the event handler(s) that
get invoked when the event is processed. The data passed in
is what is delivered to the event handler. The cancel
handle is returned to the user. This allows the event to later
be retracted using the Cancel() method.
Return: void
|
- time
- IN: Simulated time.
- eventName
- IN: String name of the event handler.
- simobjType
- IN: Simulation object type.
- simobjLocalId
- IN: LOCAL_ID of the simulation object.
- simobjNode
- IN: NODE that the simulation object is on.
- data
- IN: Variable length data that is passed to the event handler(s).
- dataBytes
- IN: Number of bytes in the data.
|
Metric Summary for OBJECTS------------------------------------------------------------------------+
Total number of classes | 3 | 11% of total |
Total number of statements | 97 | 17% of total |
Total number of free standing functions | 0 | 0% of total |
Average statements per class | 32 | 65% from average |
Average McCabe complexity per class | 26 | 71% from average |
Average number of public member functions per class | 33 | 51% from average |
Average number of protected member functions per class | 1 | 767% from average |
Average number of parameters per function | 0.9 | 7% from average |
Average number of statements per function | 1.4 | -6% from average |
Percent of functions documented | 98% | 19% from average |
#include "objman.H"
Class: C_GLOBAL_NAME
Summary: Structure for a hash table of global names
Description: Used only by C_OBJMAN
Public Interface
Public Data
int lid;
-
char name [ MAX_NAME_LENGTH ];
-
int node;
-
#include "objman.H"
Class: C_OBJMAN
Summary: Manages (creates and distributes) the C_SIMOBJs of a given type on
this node. Also, since this class inherits from C_SIMOBJ itself, it
can handle events scheduled for itself (LOCAL_ID = -1).
Description: Descendants of this class should set the variables
C_OBJMAN::N_LOC and C_OBJMAN::N_TOT, call reserve_n_objects ()
and define_object (), and increment TOTAL_OBJECTS. To card deal
this object type, use deal_me ().
Public Interface
-
-
-
INTERNAL METHOD
- simobj
- Dynamically created C_SIMOBJ to add to the simulation.
-
Virtual Method: create_object
Summary: Dynamically (and rollbackably) create a C_SIMOBJ of this C_OBJMAN's
OBJECT_TYPE
Description: Defaults to returning NULL (must be overridden)
Return: pointer to a dynamically-created C_SIMOBJ of this C_OBJMAN's
OBJECT_TYPE
-
Virtual Method: define_object
Summary: Put a C_SIMOBJ into the array of C_SIMOBJs managed by this C_OBJMAN
Description:
Return: None
- gen
- C_SIMOBJ to define.
-
Virtual Method: destroy_object
Summary: Dynamically (and rollbackably) destroy a C_SIMOBJ of this C_OBJMAN's
OBJECT_TYPE
Description: Defaults to a pass-through method (must be overridden)
Return: None
-
- C_SIMOBJ to destroy.
-
Method: get_N_LOC
Summary: Get N_LOC, which is the total number of this C_OBJMAN's type of
C_SIMOBJ on this node
Description:
Return: N_LOC
-
Method: get_N_TOT
Summary: Get N_TOT, which is the total number of this C_OBJMAN's type of
C_SIMOBJ in the simulation
Description:
Return: N_TOT
-
INTERNAL METHOD
-
INTERNAL METHOD
-
void get_nodid |
(
char* name
,
int& nd
,
int& lid
) ; |
Overloaded Method: get_nodid
Summary: Get the NODE and LOCAL_ID of the C_SIMOBJ specified by its NAME
Description:
Return: None
- name
- IN: name of C_SIMOBJ of interest.
- nd
- OUT: The NODE of the C_SIMOBJ of interest.
- lid
- OUT: The LOCAL_ID of the C_SIMOBJ of interest.
-
virtual void get_nodid |
(
int oi
,
int& n
,
int& i
) ; |
Overloaded Method: get_nodid
Summary: Get the NODE and LOCAL_ID of the C_SIMOBJ specified by its GLOBAL_ID
Description:
Return: None
- oi
- IN: The GLOBAL_ID of the C_SIMOBJ of interest.
- n
- OUT: The NODE of the C_SIMOBJ of interest.
- i
- OUT: The LOCAL_ID of the C_SIMOBJ of interest.
-
Virtual Method: get_obj
Summary: Get the C_SIMOBJ from this C_OBJMAN (ie, of this C_OBJMAN's
OBJECT_TYPE) specified by LOCAL_ID
Description:
Return: The C_SIMOBJ from this C_OBJMAN (ie, of this C_OBJMAN's OBJECT_TYPE)
specified by LOCAL_ID
- oid
- Object ID (LOCAL_ID of output C_SIMOBJ).
-
virtual void get_oid |
(
int& oi
,
int n
,
int i
) ; |
Virtual Method: get_oid
Summary: Get the GLOBAL_ID of the C_SIMOBJ specified by NODE and LOCAL_ID
Description:
Return: None
- oi
- OUT: GLOBAL_ID of C_SIMOBJ of interest.
- n
- IN: NODE of C_SIMOBJ of interest.
- i
- IN: LOCAL_ID of C_SIMOBJ of interest.
-
Virtual Method: init_events
Summary: Method in which to schedule initial events.
Description: This method is called just before the beginning of the
simulation. (I.e., just prior to simulated time = zero). This
is done so users can schedule evetns for simulated time =
zero. Users schedule initial events in each C_OBJMAN on each
node by overriding this method.
Return: None
-
Virtual Method: init_object
Summary: Initialize a particular C_SIMOBJ managed by this C_OBJMAN
Description: Defaults to a pass-through method (must be overridden)
Return: None
-
- Intended as C_SIMOBJ to initialize.
-
- Intended as initialization data.
-
INTERNAL METHOD
-
Method: print_global_names
Summary: Print the global name database to cout (see set_global_names())
Description:
Return: None
-
INTERNAL METHOD
- simobj
- C_SIMOBJ to remove from the simulation.
-
Virtual Method: reserve_n_objects
Summary: Allocate memory for an array of n pointers to the C_SIMOBJs to be
created by this C_OBJMAN
Description: By default,
Return: None
- n
- Number of objects to reserve.
-
INTERNAL METHOD
-
Method: set_N_LOC
Summary: Set N_LOC, which is the total number of this C_OBJMAN's type of
C_SIMOBJ on this node
Description: Users are responsible to set this variable in this C_OBJMAN's
constructor. This version of this overloaded method uses N_TOT
(which must be set previously by the user) and N_NODES to
determine N_LOC, using the deal_me () algorithm.
Return: None
-
Overloaded Method: set_N_LOC
Summary: Set N_LOC, which is the total number of this C_OBJMAN's type of
C_SIMOBJ on this node
Description: Users are responsible to set this variable in this C_OBJMAN's
constructor
Return: None
- n
- N_LOC.
-
Method: set_N_TOT
Summary: Set N_TOT, which is the total number of this C_OBJMAN's type of
C_SIMOBJ in the simulation
Description: Users are responsible to set this variable in this C_OBJMAN's
constructor
Return: None
- n
- N_TOT.
-
Method: set_global_names
Summary: Creates a hash table of the NAMEs of all of the C_SIMOBJs in the
simulation for easy lookups using get_nodid (char *name, int &nd,
int &lid)
Description: The purpose of this method is to ease the burden on the user
when scheduling events. This method uses global reduction
techniques to create a local data base of each C_SIMOBJ in the
simulation that has the NAME attribute defined (regardless of
what node they reside on). We recommend calling this method in
this C_OBJMAN's constructor. Then, get_nodid (char *name, int
&nd, int &lid) and print_global_names() can be called any time
during the simulation and access the database created at that
point. However, the database is not updated as C_SIMOBJs are
created and destroyed.
Return: None
-
INTERNAL METHOD
-
void term |
(
double tend
) ; |
INTERNAL METHOD
Protected Interface
-
- Local number of objects of my type.
- nobjs
- IN: total number of objects of this type to be managed collectively by all C_OBJMANs of this type on all nodes (normally N_TOT).
-
int deal_me |
(
int nobjs
,
int& offset
) ; |
Method: deal_me
Summary: card deal objects of this simulation object type for this node
Description: This function is called by this simulation type's object manager
constructor when the distribution strategy for this class of
simulation objects is to "card deal" all the simulation objects
of this type to all of the nodes in the simulation. nobjs is the
total number of objects of this type to be managed collectively
by all C_OBJMANs of this type on all nodes (normally N_TOT is
passed as the argument for this parameter). This function
returns the number of those objects that this node should manage
(the other nodes will manage the other objects). This C_OBJMAN
manages objects with ids in the calling manager of offset +
N_NODES * j, where j is a whole number. Or, another way to state
this is that offset is used to determine which C_SIMOBJs this
C_OBJMAN should manage. Namely, this C_OBJMAN manages all
C_SIMOJs of LOCAL_ID == i where ((i-offset+N_NODES)%N_NODES) ==
0 and (0 <= i < N_TOT).
Return: N_LOC
- nobjs
- IN: total number of objects of this type to be managed collectively by all C_OBJMANs of this type on all nodes (normally N_TOT).
- offset
- OUT: node offset.
Protected Data
int N_LOC;
- Local number of objects of my type.
int N_TOT;
- Total number of objects of my type.
Private Interface
Private Data
static int done;
- Pointer to the objects.
C_GLOBAL_NAME* global_name;
- Array of global names.
C_SIMOBJ** gobj;
- Pointer to the objects.
int interact;
- Interaction flag.
C_QUEUE* name_queue;
- Array of queues of global names.
ion flag int ndef;
- Number of local object defined so far.
static int ntobj;
- Number of total objects.
static int seed_update;
- Seed update.
#include "simobj.H"
Class: C_SIMOJ
Summary: A generic SPEEDES simulation object
Description: This is the fundamental modeling unit in SPEEDES applications on
which C_EVENTs act. C_SIMOBJs must be designed independent of
other C_SIMOBJs so as to permit each C_SIMOBJ to temporarily
exist at different logical (simulated) times as controlled by
the operative time management algorithm. C_SIMOBJs are permitted
to schedule events for other C_SIMOBJs, but this is generally
discouraged in favor of maximizing C_SIMOBJ reuse. To achieve
greater reuse, C_SIMOBJs should use events attached to
themselves for scheduling events for other C_SIMOBJs.
Public Interface
-
-
-
Method: AddEventHandler
Summary: Adds the event handler to the simobj. If the hash table has not
been created, it automatically creates the hash table with a
nominal size.
Description: adds the event handler to the simobj's set of event handlers.
Note that it is possible to add more than one event handler for
a specified eventName. Each eventName is managed in an item
that is stored in the EventHandlerHash table as a group.
Return: void.
-
IN: id of external module
if applicable (-1 means
event not generated by
external module)
-
Method: CheckSubType
Summary: Checks if an external module (specified by the externalId input)
has subscribed to a specified type (represented as the string Type)
Description: Searches through the EXTSUBS list for the pair <Type and
externalId> and returns 1 if found (otherwise, returns 0).
Return: Returns 1 if the subscription type for that externalId is in
the EXTSUBS list. Otherwise, returns 0.
-
Method: CheckSubscription
Summary: Checks if a subscription type specified by the input argument Name
is in the EXTSUBS list.
Description: Searches through the EXTSUBS list for the named subscription.
Return: Returns 1 if the subscription name is in the EXTSUBS list.
Otherwise, returns 0.
-
Method: EXCHANGE_SEED
Summary: Exchange the SEED of this C_SIMOBJ for rollback purposes
Description:
Return: None
- seed
- INOUT: SEED to exchange with this C_SIMOBJ's SEED.
-
Method: ProcessEventHandlers
Summary: Processes all of the event handlers with a specified name..
Description: Removes the event handler from the simobj's set of event
handlers.
Return: void.
- eventName
- IN: name of the event type.
- timeTag
- IN: simulation time.
- data
- IN: data passed to the IN: event handler.
- dataBytes
- IN: number of bytes for data.
- externalId
- IN: id of external module if applicable (-1 means event not generated by external module).
-
Method: RemoveEventHandler
Summary: Removbes the event handler from the simobj. Note that the event
name item that is in the EventHandlerHash table is never deleted.
Description: Removes the event handler from the simobj's set of event
handlers.
Return: void.
-
Method: SetEventHandlerHashSize
Summary: Sets the size of the hash table for storing event handlers.
Description: Creates the hash table for event handlers and uses the input
argument to define the size of the hash table. Reasonable sizes
for the hash table would be the number of different kinds of
event names.
Return: void.
-
INTERNAL METHOD
-
Method: event_type
Summary: Get the enumerated ID for an event type, specified by the event
type's string name
Description:
Return: the enumerated ID for an event type
- c
- IN: NAME of an event.
-
Method: get_EXTSUBS
Summary: Gets the list of external subscriptions
Description: Returns the EXTSUBS C_XQUEUE
Return: Returns the pointer to the EXTSUBS object (of type C_XQUEUE)
-
Method: get_GLOBAL_ID
Summary: Get the unique ID, simulaiton-wide, of this object. GLOBAL_ID
generated automatically, but can be overridden by the user.
Description:
Return: the unique ID of this simulation object
-
Method: get_LOCAL_ID
Summary: Get the ID of this simulation object
Description: Each object manager has its own set of C_SIMOBJs, each with
their own LOCAL_ID. Thus LOCAL_ID only needs to be unique for a
given object manager (C_OBJMAN), not unique to a given node or
to a given simulation
Return: the ID of this simulation object
-
Method: get_NAME
Summary: Get the name of this object (for referring to this C_SIMOBJ by name)
Description:
Return: name of this object
-
Method: get_NODE
Summary: Get the node (process number on local machine) that this C_SIMOBJ is
instantialted on.
Description:
Return: the node (process number on local machine) that this C_SIMOBJ
is instantialted on.
-
Method: get_N_NODES
Summary: Get the total number of nodes (process number on local machine) in
the entire simulation (including all other machines' process)
Description:
Return: total number of nodes
-
Method: get_N_OBJECT_TYPES
Summary: Get the total number of OBJECT_TYPEs (see above) in the current
simulation
Description:
Return: the total number of OBJECT_TYPEs (see above) in the current
simulation
-
Method: get_OBJECT_TYPE
Summary: Get the ID (or enumerated type) of the type of this simulation
object
Description: A unique OBJECT_TYPE is required for each C_SIMOBJ class. Each
C_SIMOBJ class is managed by one instantiation of
C_OBJMAN. Thus, the OBJECT_TYPE also uniquely defines the type
of C_SIMOBJ that each instantiation of C_OBJMAN manages. Each
node has a single instantiation of C_OBJECTS, which in turn
manages a list of C_OBJMANs. C_OBJECTS refers to each C_OBJMAN
by the OBJECT_TYPE it manages.
Return: the OBJECT_TYPE, ie, the ID of the type of this simulation type
-
Method: get_RANDOM
Summary: Get the random number generator. There is exactly one C_RANDOM
object per node, set automatically by the framework.
Description: see C_RANDOM
Return: the random number generator
-
Method: get_SEED
Summary: Get the seed for the random number generator. Must be saved and
recalled for repeatability due to rollbacks.
Description:
Return: the random number generator seed
-
INTERNAL METHOD
-
Method: get_TOTAL_OBJECTS
Summary: Get the total number of objects in the simulation. That is, the sum
of each object of each object type on each node.
Description:
Return: the total number of objects in the simulation
-
INTERNAL METHOD
-
INTERNAL METHOD
-
INTERNAL METHOD
-
INTERNAL METHOD
-
INTERNAL METHOD
-
Method: get_manager
Summary: Get the object manager for another simulation object, specified by
its OBJECT_TYPE
Description:
Return: an object manager, casted to (void *)
- om
- IN: OBJECT_TYPE of the desired object manager.
-
Method: get_monitor
Summary: Get the number of external monitors connected to this simulation
object
Description:
Return: the number of external monitors connected to this simulation
object
-
INTERNAL METHOD
-
INTERNAL METHOD
-
INTERNAL METHOD
-
Method: get_qmon
Summary: Get the list of external monitors connected to this simulation
object
Description:
Return: the list of external monitors connected to this simulation object
-
INTERNAL METHOD
-
INTERNAL METHOD
-
INTERNAL METHOD
-
INTERNAL METHOD
-
INTERNAL METHOD
-
Method: object_type
Summary: Retrieves a simulation object's OBJECT_TYPE (see set_OBJECT_TYPE)
based on its string NAME
Description:
Return: the object type of this simulation object
-
Virtual Method: print
Summary: User-overridable function to print something about this simulation
object during run-time
Description:
Return: None
-
INTERNAL METHOD
-
virtual void query |
(
double time_tag
,
NAME_VALUE_LIST& NameValueList
) ; |
Virtual Method: query
Summary: Query this simulation object for a name-value list of information
Description: Simulation objects can be queried during run-time for real-time
updates of their state. The state information queried is defined
by the simulation object at compile time by overridding this
virtual function.
Return: the size, in bytes, of the returned buffer, buff
- time_tag
- IN: simulated time for the query.
- NameValueList
- OUT: query list.
-
INTERNAL METHOD
- it
- IN: the event to remove from this node's list of blocking events.
-
INTERNAL METHOD
-
void* schedule |
(
const SIMTIME& time
,
int event_type
,
int object_type
,
int object_id
,
int object_node
) ; |
Overloaded Method: schedule
Summary: Schedule an event at the present or a future simulated time for any
simulation object (C_SIMOBJ) in the simulation
Description: For reusability, prefer scheduling events in the process user
code of events (C_EVENTs). See the schedule methods in C_EVENT.
Return: the message for this scheduled event
- time
- IN: simulated time.
- event_type
- IN: enumerated or integer type of event to schedule.
- object_type
- IN: enumerated or integer type of object for which to schedule the event (must be the one type of object required for the event_type).
- object_id
- IN: the LOCAL_ID of the object for which to schedule the event.
- object_node
- IN: the NODE of the object for which to schedule the event.
-
void* schedule |
(
double time
,
int event_type
,
int object_type
,
int object_id
,
int object_node
) ; |
Overloaded Method: schedule
Summary: Schedule an event at the present or a future simulated time for any
simulation object (C_SIMOBJ) in the simulation
Description: For reusability, prefer scheduling events in the process user
code of events (C_EVENTs). See the schedule methods in C_EVENT.
Return: the message for this scheduled event
- time
- IN: simulated time as a double (ie, no priority fields).
- event_type
- IN: enumerated or integer type of event to schedule.
- object_type
- IN: enumerated or integer type of object for which to schedule the event (must be the one type of object required for the event_type).
- object_id
- IN: the LOCAL_ID of the object for which to schedule the event.
- object_node
- IN: the NODE of the object for which to schedule the event.
-
void* schedule |
(
const SIMTIME& time
,
int event_type
,
int object_type
,
int object_id
,
int object_node
,
int size
,
char*& buf
) ; |
Overloaded Method: schedule
Summary: Schedule an event at the present or a future simulated time for any
simulation object (C_SIMOBJ) in the simulation
Description: For reusability, prefer scheduling events in the process user
code of events (C_EVENTs). See the schedule methods in C_EVENT.
Return: the message for this event
- time
- IN: simulated time.
- event_type
- IN: enumerated or integer type of event to schedule.
- object_type
- IN: enumerated or integer type of object for which to schedule the event (must be the one type of object required for the event_type).
- object_id
- IN: the LOCAL_ID of the object for which to schedule the event.
- object_node
- IN: the NODE of the object for which to schedule the event.
- size
- IN: (OPTIONAL) number of bytes of the variable-length part of the event message.
- buf
- IN: (USED IF AND ONLY IF "size" IS USED) the variable-length part of the event message.
-
Method: set_GLOBAL_ID
Summary: Set the unique ID, simulaiton-wide, of this object. GLOBAL_ID
generated automatically, but can be overridden by the user with this
method.
Description:
Return: None
-
INTERNAL METHOD
-
INTERNAL METHOD
-
INTERNAL METHOD
-
INTERNAL METHOD
-
INTERNAL METHOD
-
INTERNAL METHOD
-
INTERNAL METHOD
-
INTERNAL METHOD
-
INTERNAL METHOD
-
INTERNAL METHOD
-
INTERNAL METHOD
-
INTERNAL METHOD
-
INTERNAL METHOD
-
INTERNAL METHOD
-
INTERNAL METHOD
-
INTERNAL METHOD
-
INTERNAL METHOD
-
INTERNAL METHOD
-
Virtual Method: terminate
Summary: User-overridable function for operations (such as printing
statistics) associated with this simulation object to be performed
when the simulation completes
Description:
Return: None
-
- The simulation passes the end time of the simulation here (tend). Using this value is of course optional.
-
INTERNAL METHOD
- soc
- IN: the socket ID to unblock.
-
INTERNAL METHOD
-
INTERNAL METHOD
- it
- IN: the event after which the current event is to be inserted.
-
INTERNAL METHOD
- it
- IN: the event after which the current event is to be inserted.
-
INTERNAL METHOD
Protected Interface
Protected Data
C_XQUEUE EXTSUBS;
- Requested external subscriptions.
int GLOBAL_ID;
- Unique id for simulation.
char* NAME;
- Name of object.
static int NODE;
- Node id.
static int N_NODES;
- The total number of nodes.
static int N_OBJECT_TYPES;
- Number of object types.
int OBJECT_TYPE;
- Object type.
static C_RANDOM* RANDOM;
- Shared random number generator.
STATE_INT SEED;
- Random number SEED.
SIMTIME TIME;
- Time of object GEB3.
static int TOTAL_OBJECTS;
- Total number of objects created.
int id;
- Local object id.
static C_RBQ* rbq;
- Roll back queue object.
Private Interface
Private Data
C_XHASH* EventHandlerHash;
- Manages event handlers.
C_XQUEUE cancel_queue;
- Queue of canceled events.
static int done;
- Done flag (first simobj created).
C_DBL_QUEUE evtq;
- Event queue for object.
static void* evtype;
- Evtype manages event creation.
static C_QUEUE* init_events;
- Initial event queue.
int last_etype;
- Last event type of object.
C_RQUEUE local_rqueue;
- Speedes queue for this object.
static int nlobjs;
- Number of local objects.
static C_OBJECT_TYPES* obman;
- Object manager constructor.
static C_QUEUE* qblock;
- Queue of blocking events.
C_QUEUE qmon;
- Queue of external monitors.
static C_QUEUE* qunblock;
- Queue of unblocking events.
C_RQ_HOLDER* rq_holder;
- Rqueue holder for the object.
static C_RQUEUE* rqueue;
- Speedes queue for local objects.
static int uid_seed;
- Unique id for this object.
Metric Summary for ROLLBACKABLE OPERATIONS------------------------------------+
Total number of classes | 7 | 26% of total |
Total number of statements | 123 | 21% of total |
Total number of free standing functions | 0 | 0% of total |
Average statements per class | 18 | -10% from average |
Average McCabe complexity per class | 11 | -25% from average |
Average number of public member functions per class | 11 | -50% from average |
Average number of protected member functions per class | 0 | -100% from average |
Average number of parameters per function | 0.7 | -15% from average |
Average number of statements per function | 1.7 | 16% from average |
Percent of functions documented | 14% | -82% from average |
#include "state_variable.H"
INTERNAL METHODSummary: Holds the C_RBQ (rollback queue manager) for all the rollbackable
classes that inherit from this
Description:
Public Interface
-
-
Protected Interface
Protected Data
static C_RBQ* rbq;
-
#include "state_variable.H"
Class: RB_ostream
Summary: Rollbackable ostream
Description: Use this just as you would a normal ostream when that ostream
is part of the state of a C_SIMOBJ or non-C_SIMOBJ object (ie,
when it needs to be rollbackable)
Public Interface
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Private Interface
Private Data
ofstream filestream;
-
ostream* outstream;
- Either a file or cout.
int toFile_p;
- Is output going to a file?
#include "state_variable.H"
State_double object.
Class: STATE_DOUBLE (typedef'd to RB_double)
Summary: Rollbackable double
Description: Use this just as you would a normal double when that double
is part of the state of a C_SIMOBJ or non-C_SIMOBJ object (ie,
when it needs to be rollbackable)
Public Interface
-
-
-
-
-
- ...... Conversion method allows this object to be used as a double.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- ...... Other methods.
Public Data
double state_variable;
-
#include "state_variable.H"
Class: STATE_FLOAT (typedef'd to RB_float)
Summary: Rollbackable float
Description: Use this just as you would a normal float when that float
is part of the state of a C_SIMOBJ or non-C_SIMOBJ object (ie,
when it needs to be rollbackable)
Public Interface
-
-
-
-
-
- ...... Conversion method allows this object to be used as a double.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- ...... Other methods.
Public Data
float state_variable;
-
#include "state_variable.H"
Class: STATE_INT (typedef'd to RB_int)
Summary: Rollbackable integer
Description: Use this just as you would a normal integer when that integer
is part of the state of a C_SIMOBJ or non-C_SIMOBJ object (ie,
when it needs to be rollbackable)
Public Interface
-
-
-
-
-
-
-
- ...... Conversion method allows this object to be used as an int.
-
- ...... Overloading new and delete operators.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- ...... Other methods.
Public Data
int state_variable;
-
#include "state_variable.H"
State_pointer object.
Description: Use this just as you would a normal when that
is part of the state of an C_SIMOBJ or non-C_SIMOBJ object (ie,
when it needs to be rollbackable)
Class: STATE_POINTER (typedef'd to RB_pointer)
Summary: Rollbackable pointer
Description: Use this just as you would a normal void or character pointer on
the right-hand side of equations when that pointer is part of
the state of a C_SIMOBJ or non-C_SIMOBJ object (ie, when it
needs to be rollbackable). In addition to regular use on the
right-hand side of equations as a void or character pointer,
this object can be rollbackably set equal to another void
pointer using the = operator. The = operator is the only
left-hand side of equations operator supported.
Public Interface
-
-
-
-
-
-
-
- ...... Conversion method allows this object to be used as a void* or char.
-
-
-
-
-
- ...... Other methods.
Public Data
void* state_variable;
-
#include "state_variable.H"
State_string object.
Class: STATE_STRING (typedef'd to RB_string)
Summary: Rollbackable character pointer
Description: Use this just as you would a normal character pointer on the
right-hand side of equations when that character pointer is part
of the state of a C_SIMOBJ or non-C_SIMOBJ object (ie, when it
needs to be rollbackable). In addition to regular use on the
right-hand side of equations as a character pointer, this object
can be set equal to another character pointer using the =
operator, and the string that the other character pointer points
to will be rollbackably copied to this character pointer. Memory
management is handled automatically. The = operator is the only
left-hand side of equations operator supported.
Public Interface
-
-
-
-
-
-
-
- ...... Conversion method allows this object to be used as a char.
-
-
-
-
-
-
-
-
-
- ...... Other methods.
Public Data
char* state_variable;
-
Metric Summary for SIMULATED TIME---------------------------------------------------------+
Total number of classes | 1 | 3% of total |
Total number of statements | 77 | 13% of total |
Total number of free standing functions | 7 | 30% of total |
Average statements per class | 69 | 253% from average |
Average McCabe complexity per class | 44 | 193% from average |
Average number of public member functions per class | 34 | 55% from average |
Average number of protected member functions per class | 0 | -100% from average |
Average number of parameters per function | 1.2 | 49% from average |
Average number of statements per function | 1.9 | 29% from average |
Percent of functions documented | 76% | -9% from average |
Class Metrics
Class | Public Members | Statements | McCabe Complexity |
SIMTIME | 34 | 69 | 44 |
#include "simtime.H"
Class: SIMTIME
Summary: An abstract representation of simulated time
Description: SIMTIME uses a double for representing the physical time and
then two integer priority fields for breaking physical time
ties. This is for repeatability when on multiple nodes and
rollbacks are involved. Since rollbacks are not repeatable, when
events are rescheduled, there must be a way to order them the
same way each time they are reprocessed. Since physical times
are often the same, priorities are needed to indicate the order
in which events which have the same physical time are to be
processed. The first priority field has precedence over the
second priority field. The combination of the physical time and
the two priority fields is called logical time. Repeatable
rollbackable simulations are assured only if events always
schedule new events in future logical time. In other words,
scheduling must either have physical time non-zero lookahead, or
physical time zero lookahead with higher priority values
(meaning later logical time) than the priorities of the current
event.
Public Interface
-
SIMTIME |
(
double t = DefaultTime
,
int p1 = DefaultPriority1
,
int p2 = DefaultPriority2
) ; |
Constructor: SIMTIME (same as SetValues ())
Summary: Set the three values in the SIMTIME object
Description: The three values are 1. physical time, 2. first priority
field, 3. second priority field.
- t
- Physical time.
- p1
- First priority field.
- p2
- Second priority field.
-
Method: operator =
Summary: When assigned to another SIMTIME, this SIMTIME undergoes an
element-by-element copy, INCLUDING CHANGING ITS PRIORITIES
Description:
Return: A reference to this SIMTIME object
-
Method: operator =
Summary: When assigned to a double, SIMTIME assigns that double to its
physical time WITHOUT CHANGING ITS PRIORITIES
Description:
Return: A reference to this SIMTIME object
-
Method: operator double
Summary: When used as a primitive, SIMTIME automatically converts to a double
representing its physical time
Description:
Return: The physical time
-
-
-
Method: operator !=
Summary: Perform a not-equal logical time comparison between this SIMTIME and
another SIMTIME
Description: That this is a logical time comparison means that the physical
time is compared and if they are equal, the first priority
fields are compared and if they are equal, the second priority
fields are compared
Return: Whether this SIMTIME is not equal to the specified SIMTIME in logical
time
-
Method: operator +=
Summary: When add-assigned to another SIMTIME, SIMTIME adds that double to
its physical time INCLUDING CHANGING ITS PRIORITIES
Description:
Return: A reference to this SIMTIME object
-
Method: operator +=
Summary: When add-assigned to a double, SIMTIME adds that double to its
physical time WITHOUT CHANGING ITS PRIORITIES
Description:
Return: A reference to this SIMTIME object
-
Method: operator -=
Summary: When substract-assigned to another SIMTIME, SIMTIME subtracts that
double from its physical time INCLUDING CHANGING ITS PRIORITIES
Description:
Return: A reference to this SIMTIME object
-
Method: operator -=
Summary: When subtract-assigned to a double, SIMTIME subtracts that double
from its physical time WITHOUT CHANGING ITS PRIORITIES
Description:
Return: A reference to this SIMTIME object
-
Method: operator <
Summary: Perform a less-than logical time comparison between this SIMTIME and
another SIMTIME
Description: That this is a logical time comparison means that the physical
time is compared and if they are equal, the first priority
fields are compared and if they are equal, the second priority
fields are compared
Return: Whether this SIMTIME is earlier than the specified SIMTIME in
logical time
-
- Comparison operators between a SIMTIME and a double.
-
-
-
Method: operator <=
Summary: Perform a less-than-or-equal logical time comparison between this
SIMTIME and another SIMTIME
Description: That this is a logical time comparison means that the physical
time is compared and if they are equal, the first priority
fields are compared and if they are equal, the second priority
fields are compared
Return: Whether this SIMTIME is earlier or equal to the specified SIMTIME in
logical time
-
-
-
Method: operator ==
Summary: Perform an equality logical time comparison between this SIMTIME and
another SIMTIME
Description: That this is a logical time comparison means that the physical
time is compared and if they are equal, the first priority
fields are compared and if they are equal, the second priority
fields are compared
Return: Whether this SIMTIME is equal to the specified SIMTIME in logical
time
-
-
-
Method: operator >
Summary: Perform a greater-than logical time comparison between this SIMTIME
and another SIMTIME
Description: That this is a logical time comparison means that the physical
time is compared and if they are equal, the first priority
fields are compared and if they are equal, the second priority
fields are compared
Return: Whether this SIMTIME is later than the specified SIMTIME in
logical time
-
-
-
Method: operator >=
Summary: Perform a greater-than-or-equal logical time comparison between this
SIMTIME and another SIMTIME
Description: That this is a logical time comparison means that the physical
time is compared and if they are equal, the first priority
fields are compared and if they are equal, the second priority
fields are compared
Return: Whether this SIMTIME is later or equal to the specified SIMTIME in
logical time
-
Method: DecrementPriority1
Summary: Subtract a specified amount from the first priority field (default=1)
Description:
Return: None
- value
- Amount to subtract from first priority field.
-
Method: DecrementPriority2
Summary: Subtract a specified amount from the second priority field (default=1)
Description:
Return: None
- value
- Amount to subtract from second priority field.
-
Method: GetPriority1
Summary: Get the first priority field
Description:
Return: The first priority field value
-
Method: GetPriority2
Summary: Get the second priority field
Description:
Return: The second priority field
-
Method: GetTime
Summary: Get the physical time
Description:
Return: The physical time
-
Method: IncrementPriority1
Summary: Add a specified amount to the first priority field (default=1)
Description:
Return: None
- value
- Amount to add to first priority field.
-
Method: IncrementPriority2
Summary: Add a specified amount to the second priority field (default=1)
Description:
Return: None
- value
- Amount to add to first priority field.
-
Overloaded Method: SetPriority (same as SetPriority1)
Summary: Set the first priority field
Description:
Return: None
- p1
- First priority field value.
-
Overloaded Method: SetPriority
Summary: Set the first and second priority fields
Description:
Return: None
- p1
- First priority field value.
- p2
- Second priority field value.
-
Method: SetPriority1 (same as SetPriority)
Summary: Set the first priority field
Description:
Return: None
- p
- First priority field value.
-
Method: SetPriority2
Summary: Set the second priority field
Description:
Return: None
- p
- Second priority field value.
-
Method: SetTime
Summary: Set the physical time
Description:
Return: None
- t
- Physical time.
-
void SetValues |
(
double t = DefaultTime
,
int p1 = DefaultPriority1
,
int p2 = DefaultPriority2
) ; |
Method: SetValues
Summary: Set the three values in the SIMTIME object
Description: The three values are 1. physical time, 2. first priority
field, 3. second priority field.
Return: None
- t
- Physical time.
- p1
- First priority field.
- p2
- Second priority field.
-
void print |
(
ostream& out = cout
) ; |
Method: print
Summary: Print the SIMTIME object's values
Description:
Return: None
- out
- Ostream object to which to print.
Protected Interface
Protected Data
NET_INT Priority1;
- First tie breaker.
NET_INT Priority2;
- Second tie breaker.
NET_DOUBLE Time;
- Physical time.
int operator!=(double t
,
const SIMTIME& tt
) ;
|
|
int operator<(double t
,
const SIMTIME& tt
) ;
|
Operators when the double is on the left side. |
ostream& operator<<(ostream& out
,
const SIMTIME& tt
) ;
|
Method: operator <<
Summary: Print the comtents of this SIMTIME to an ostream
Description:
Return: The specified ostream
|
- out
- The ostream to which to print.
- tt
- SIMTIME to print.
|
int operator<=(double t
,
const SIMTIME& tt
) ;
|
|
int operator==(double t
,
const SIMTIME& tt
) ;
|
|
int operator>(double t
,
const SIMTIME& tt
) ;
|
|
int operator>=(double t
,
const SIMTIME& tt
) ;
|
|
Metric Summary for Utilities
Total number of classes | 14 | 53% of total |
Total number of statements | 155 | 27% of total |
Total number of free standing functions | 12 | 52% of total |
Average statements per class | 10 | -50% from average |
Average McCabe complexity per class | 8 | -47% from average |
Average number of public member functions per class | 17 | -21% from average |
Average number of protected member functions per class | 0 | -100% from average |
Average number of parameters per function | 0.7 | -12% from average |
Average number of statements per function | 1.3 | -11% from average |
Percent of functions documented | 90% | 9% from average |
Metric Summary for MISCELLANEOUS----------------------------------------------------------+
Total number of classes | 5 | 19% of total |
Total number of statements | 50 | 8% of total |
Total number of free standing functions | 0 | 0% of total |
Average statements per class | 10 | -49% from average |
Average McCabe complexity per class | 7 | -51% from average |
Average number of public member functions per class | 21 | -3% from average |
Average number of protected member functions per class | 0 | -100% from average |
Average number of parameters per function | 0.9 | 14% from average |
Average number of statements per function | 1.4 | -2% from average |
Percent of functions documented | 95% | 15% from average |
#include "free_list.H"
Class: C_FREE_LIST
Summary: Manager of all of the freelists on a node
Description: This class can manage multiple freelist object types (ie, manage
many freelists, each with a separate freelist type ID
corresponding to a C++ class). new_object () and delete_object()
are the fundamental calls for the C_FREELIST class. They replace
calling new and delete directly by saving no-longer-needed
objects when calling delete_object() and then returning pointers
to those no-longer-needed objects when calling new_object()
(which is much faster than dynamically allocating a new one) if
possible. If a freelist object type has no available old copies,
then calling new_object() dynamically creates a new one and
returns it. The name "freelist" refers to the list of currently
no-longer-needed, but not deleted, objects that are available
for future use.
Public Interface
-
-
-
void CopyType |
(
char* NewName
,
int NewType
,
int OldType
) ; |
Method: CopyType
Summary: Create a new freelist type with a new name by copying the
constructor, size and neach attributes from an old (already
existing) freelist type
Description:
Return: None
- NewName
- Name of new freelist type.
- NewType
- Type ID of new type.
- OldType
- Type ID of old type.
-
Method: GetName
Summary: Get the name of the i'th freelist
Description:
Return: The name of the i'th freelist
- i
- Element ordering of the desired freelist name.
-
Method: GetNames
Summary: Get a pointer to the first element of the array of names of
freelists
Description:
Return: Freelist name array
-
Method: GetNtypes
Summary: Get the number of type IDs of freelists
Description:
Return: The number of type IDs of freelists (ntypes)
-
the freelist's freelist object type ID
into which this object is to be placed
-
Method: delete_list
Summary: Add a list of objects back into a free list
Description:
Return: None
- q
- Object list to delete.
- type
- Objec\t type ID to delete.
-
Overloaded Method: delete_object
Summary: Put a no longer needed object, whose state currently contains a
freelist object type ID, into its freelist
Description: This and new_object() are the fundamental calls for the
C_FREELIST class. They replace calling new and delete directly
by saving no-longer-needed objects when calling delete_object()
and then returning pointers to those no-longer-needed objects
when calling new_object() (which is much faster than dynamically
allocating a new one) if possible. If a freelist object type has
no available old copies, then calling new_object() dynamically
creates a new one and returns it. The name "freelist" refers to
the list of currently no-longer-needed, but not deleted, objects
that are available for future use. Returned objects are casted
to (void *) and are not necessarily in their initialized
state. Use this version of this method when the object already
has a freelist object type ID. If this object has used the other
version of this method before, then this version can be used
thereafter. Or, if its freelist object type ID has been set by
some other means, this version can be used.
Return: None
- object
- Object to put into its freelist, casted to (void *).
-
Overloaded Method: delete_object
Summary: Put a no longer needed object, which has possibly never participated
in freelists before, into a freelist specified by freelist object
type ID
Description: This and new_object() are the fundamental calls for the
C_FREELIST class. They replace calling new and delete directly
by saving no-longer-needed objects when calling delete_object()
and then returning pointers to those no-longer-needed objects
when calling new_object() (which is much faster than dynamically
allocating a new one) if possible. If a freelist object type has
no available old copies, then calling new_object() dynamically
creates a new one and returns it. The name "freelist" refers to
the list of currently no-longer-needed, but not deleted, objects
that are available for future use. Returned objects are casted
to (void *) and are not necessarily in their initialized
state. Use this version of this method when the object does not
yet have (or may not have) a freelist object type ID, but is the
type associated with the specified freelist object type ID. If
this object has never set its freelist object type ID and has
never been the calling argument in this version of this method
before, then this version must be used, and then the other
version of this method can be used thereafter.
Return: None
- object
- An object of the type associated with the freelist object type ID specified by this method's second argument, casted to (*void).
- type
- The freelist's freelist object type ID into which this object is to be placed.
-
- Objec\t type ID to delete.
- buff
- Buffer from which to generate an object.
-
Overloaded Method: get_size
Summary: Get the size of a freelist object type
Description:
Return: The size of the specified freelist object type
- type
- Freelist object type ID.
-
Overloaded Method: get_size
Summary: Get the size of a freelist object type
Description: The specified object must inherit from C_ITEM, or SPEEDES has
undefined behavior. If it is a C_ITEM but not part of a
freelist, -1 is returned.
Return: The size of the freelist object type of the specified object, or -1
if this object is not part of a freelist
- object
- Pointer to an object, casted to void.
-
Method: new_object
Summary: Get or construct an object of an existing freelist object type ID
Description: This and delete_object() are the fundamental calls for the
C_FREELIST class. They replace calling new and delete directly
by saving no-longer-needed objects when calling delete_object()
and then returning pointers to those no-longer-needed objects
when calling new_object() (which is much faster than dynamically
allocating a new one) if possible. If a freelist object type has
no available old copies, then calling new_object() dynamically
creates a new one and returns it. The name "freelist" refers to
the list of currently no-longer-needed, but not deleted, objects
that are available for future use. Returned objects are casted
to (void *) and are not necessarily in their initialized state.
Return: An object of the specified type
- type
- An existing freelist object type ID.
-
void print |
(
ostream& out = cout
) ; |
Method: print
Summary: Print out status information for the free list
Description:
Return: None
- out
- Ostream to which to print.
-
Method: set_ntypes
Summary: Set (and create) n types of freelist objects
Description: When called the first time, this function allocates an array of
n elements of size, neach, ncreated, name, constructor,
qfree. These are the necessary attributes for each freelist
object type. When called after the first time, it moves these
arrays to new places in memory and adds or subtracts elements to
the new array.
Return: None
- n
- Number of freelist types.
-
void set_type |
(
char* nam
,
int type
,
void* (* f ) ( int )
,
int sz
,
int n
) ; |
Method: set_type
Summary: Sets the name, constructor, size, and neach for a specified freelist
object type
Description:
Return: None
Private Interface
Private Data
void** constructor;
-
char** name;
-
int* ncreated;
-
int* neach;
-
int ntypes;
-
C_QUEUE* qfree;
-
int* size;
-
#include "holder.H"
Class: C_HOLDER
Summary: A C_ITEM with an size-unlimited character buffer in it and the
node to which it is supposed to arrive when sent as a message
Public Interface
-
-
-
Constructor Method:
Summary: Initialize the data in the object
Description:
- b
- IN: character buffer of which this object is a holder.
- s
- IN: size of character buffer, in bytes.
- n
- IN: node to which this C_HOLDER is supposed to arrive when sent as a message.
-
void get |
(
char*& b
,
int& s
,
int& n
) ; |
Method: get
Summary: Get all the data in this C_HOLDER
Description:
Return: None
- b
- OUT: character buffer of which this object is a holder.
- s
- OUT: size of character buffer, in bytes.
- n
- OUT: node to which this C_HOLDER is supposed to arrive when sent as a message.
-
Method: get_buff
Summary: Get the character buffer of which this object is a holder, in bytes
Description:
Return: The buffer
-
Method: get_node
Summary: Get the node to which this C_HOLDER is supposed to arrive when sent
as a message
Description:
Return: The node to which this C_HOLDER is supposed to arrive when sent as a
message
-
Method: get_size
Summary: Get the size of the character buffer of which this object is a
holder, in bytes
Description:
Return: The size of the buffer, in bytes
-
void set |
(
char* b
,
int s
,
int n
) ; |
Method: set
Summary: Set all the data in this C_HOLDER
Description:
Return: None
- b
- IN: character buffer of which this object is a holder.
- s
- IN: size of character buffer, in bytes.
- n
- IN: node to which this C_HOLDER is supposed to arrive when sent as a message.
-
Method: set_node
Summary: Set the node to which this C_HOLDER is supposed to arrive when sent
as a message
Description:
Return: None
Private Interface
Private Data
char* buff;
- Pointer to a buffer.
int node;
- Node that the buffer should be sent to.
int size;
- Size of the buffer.
#include "random.H"
Class: C_RANDOM
Summary: Random number generator (one per node)
Description: Use this class to generate random numbers. It keeps track of
its seed automatically, but not rollbackably. For rollbacks,
the seed must be saved by the simulation objects unless the
process model is being used, in which case rollbackable random
numbers is supported automatically.
Public Interface
-
-
-
Method: compute_beta_fF
Summary: Computes the beta density distributions f and F
Description:
Return: None
- tt
- IN: t.
- ff
- OUT: beta density distributions f.
- FF
- OUT: beta density distributions F.
-
double erf |
(
double x
) ; |
INTERNAL METHOD
-
INTERNAL METHOD
- n
- IN: specified integer.
-
Method: get_random_beta
Summary: Get a random beta number
Description:
Return: A random beta number
-
INTERNAL METHOD
-
Method: get_random_bits
Summary: Generate a random integer with a specified number of bits
Description: Uses the generate-random-bits (slower but more random) algorithm
Return: A random integer with a specified number of bits
- nbits
- IN: specified number of bits.
-
Method: get_random_exp
Summary: Generate a random float (double) according to an exponential
distribution with parameters set by the last call to set_exp ()
Description:
Return: A random float (double) according to an exponential distribution
-
Overloaded Method: get_random_float
Summary: Generate a random float (double) between the low limit and high
limit as last set by set_float_limits ()
Description: Uses the algorithm specified by the last call to either
set_fast () or set_slow ()
Return: A random float (double)
-
Overloaded Method: get_random_float
Summary: Generate a random integer with a specified number of bits
Description: Uses the generate-random-bits (slower but more random) algorithm
Return: A random integer with a specified number of bits
- nbits
- IN: specified number of bits.
-
Method: get_random_gauss
Summary: Generate a random float (double) according to a gaussian
distribution with parameters set by the last call to set_gauss ()
Description:
Return: A random float (double) according to a gaussian distribution
-
Method: get_random_int
Summary: Generate a random integer between the low limit and high limit as
last set by set_int_limits ()
Description: Uses the algorithm specified by the last call to either
set_fast () or set_slow ()
Return: A random integer
-
INTERNAL METHOD
-
Method: get_random_mag_vector
Summary: Generate a random magnitude vector
Description: This first generates a unit vector, then multiplies the
magnitude by a random gaussian with sigma=1 and mean=0, and then
multiplies that number by each of the components of the unit
vector
Return: None
- mag
- IN: magnitude.
-
- OUT: magnitude vector.
-
Method: get_random_unit_vector
Summary: Generate a random unit vector
Description:
Return: None
-
- OUT: unit vector.
-
Method: get_seed
Summary: Get the seed for this generator
Description:
Return: The seed for this generator
-
INTERNAL METHOD
-
INTERNAL METHOD
-
INTERNAL METHOD
-
INTERNAL METHOD
-
INTERNAL METHOD
-
INTERNAL METHOD
-
INTERNAL METHOD
-
INTERNAL METHOD
-
INTERNAL METHOD
-
Method: set_beta
Summary: Set n1 and n2 for beta distributions
Description:
Return: None
- n1
- IN: n1.
- n2
- IN: n2.
-
Method: set_exp
Summary: Set lambda for random exponential distributions
Description:
Return: None
- l
- IN: lambda.
-
Method: set_fast
Summary: Set the generator to linear-congruential mode (far faster than
generate-random-bits mode, and far more cycles before the random
number cycle repeats, but far less even random number distribution)
Description:
Return: None
-
Method: set_float_limits
Summary: Set the low and high limits for random floats (doubles)
Description: These variables become state for this object. Since there is
only one of this object per node, this method should be called
at least once per event where random floats are generated.
Return: None
- l
- IN: low limit for random floats.
- h
- IN: high limit for random floats.
-
Method: set_gauss
Summary: Set sigma and mean for random gaussian distributions
Description:
Return: None
- s
- IN: sigma.
- m
- IN: mean.
-
Method: set_int_limits
Summary: Set the low and high limits for random integers
Description: These variables become state for this object. Since there is
only one of this object per node, this method should be called
at least once per event where random integers are generated.
Return: None
- l
- IN: low limit for random integers.
- h
- IN: high limit for random integers.
-
Method: set_seed
Summary: Set the seed for this generator
Description:
Return: None
- sd
- IN: seed.
-
Method: set_slow
Summary: Set the generator to generate-random-bits mode (far slower than
linear-congruential mode, and far less cycles before the random
number cycle repeats (256,000 cycles), but far more even random
number distribution)
Description:
Return: None
Private Interface
Private Data
double* beta_coeff_F;
- Coefficients for the cum. Beta function.
double* beta_coeff_f;
- Coefficients for the beta function.
double beta_n1;
- Beta function n1.
double beta_n2;
- Beta function n2;
int fastmode;
- Flag for fast random number generation.
double fhi;
- Upper limit for float random numbers.
double flo;
- Lower limit for float random numbers.
int gaussflag;
- Flag for an extra gaussian value available.
double gaussvalue;
- Extra gaussian value.
int hi;
- Upper limit for integer random numbers.
double lambda;
- Lambda for exponential distributions.
int lo;
- Lower limit for integer random numbers.
double mean;
- Mean for gaussian distributions.
double scaler;
- Maximum integer random number.
int seed;
- Random number seed (used by everthing).
double sigma;
- Sigma for gaussian distributions.
#include "DataParser.H"
Class: DATA_PARSER
Summary: Object that reads in an input file and provides data for
applications.
Description: This DATA_PARSER is designed to parse files of the format
exemplified by:
// begin example *.par file
Set_1
{
int i_1 14
reference Group_1 Set_2
reference Group_1 Set_3
Group_1 Set_4
{
int i 40
}
Set_5
{
int 1 50
}
int i_2 16
enum e_1
string s_1 happy
float f_1 1.4
logical l_1 T
}
Set_2
{
int i 20
}
Set_3
{
int i 30
}
// end example *.par file
DEFINITIONS:
-Top-Level Set: A named, braced collection of primitives and/or
embedded sets that is not embedded in another
set
-Embedded Set: A named, braced collection of primitives and/or
embedded sets that is embedded in another set
-Reference Set: An alias of (ie, a specifier to include) a
top-level set embedded in either a top-level
set or an embedded set
-Set Group: A collection of embedded sets and/or reference
sets nested one level into a top-level set or
an embedded set unified by a common group
name for the purpose of accessing each set in
the group in turn via a loop control structure
-Group Name: The string tag that unifies a set group
-Primitive: A named value of one of the fundamental units
of data extractable by the DATA_PARSER,
consisting of one of the following types:
integer, enumeration, logical, float, string,
or define
KEYWORDS:
-"reference": specifies a set as a reference set, followed
by a group name, followed by a top-level set
name
-"int": specifies a integer primitive, followed by a
variable name, followed by a value
-"enum": specifies a enumeration primitive, followed by
a variable name, followed by a value
-"logical": specifies a logical primitive, followed by a
variable name, followed by a value
-"float": specifies a floating point primitive, followed
by a variable name, followed by a value
-"string": specifies a string primitive, followed by a
variable name, followed by a value
-"define": specifies a define primitive, followed by a
variable name, followed by a value
OVERVIEW:
Methods are provided to move in and out of top-level
sets (such as "Set_1" above), embedded sets (such as
"Set_4" above), and reference sets (such as "Set_2"
nested in "Set_1" above). The set to which the user has
most recently moved is called the current set. Get*()
methods are provided to extract primitive data (such as
ints, floats, etc.) from the current set. Sets are
reference sets when preceded by two words: the key word
"reference" and a group name. Reference sets are nested
sets that are actually an inline inclusion of a
top-level set of the same set name. Sets may be grouped
together for the user to loop through them by having a
common group name (such as "Group_1" in the above
example). Sets that are members of a group may be
reference sets (such as "Set_2" nested in "Set_1"
above) or embedded sets (such as "Set_4" above). When
looping through a group (call it Group_1) nested one
level into a set (call it Set_1), the current set
changes each iteration of the loop to the nested set in
Group_1 currently arrived at by the loop. This set be
inline or a "reference" to a top-level set. At any
point during set_a's loop through Group_1, the user may
MoveIn () to the current set in Group_1, perform any
Get*()'s, loop through groups, perform nested
MoveIn()'s and MoveOut()'s, and then finally MoveOut ()
back to Set_1 and continue where Set_1 left off in its
loop through Group_1.
Implementation: The DATA_PARSER handles such nested navigation
through a *.par file through internally keeping
track of a stack of pointers to sets. It "pushes" a
set pointer onto this stack when the user calls
MoveIn() or MoveToFirstSetInGroup(), "pops" set
pointer(s) off this stack when the user calls
MoveOut () or MoveOutCompletely (), and both "pops"
and "pushes" a set pointer when the user calls
MoveToNextSetInGroup ().
Public Interface
-
Constructor Method: DATA_PARSER
Summary: Construct a DATA_PARSER with the file it is so parse
Description: The data parser must always be constructed with the file it is
to parse. Thus each DATA_PARSER is designed to parse one and
only one file. To parse multiple files, simply create multiple
DATA_PARSERs.
- fileName
- File to be parsed.
-
-
-
void* Find |
(
void* Mark
,
char* ReferenceName
) ; |
INTERNAL METHOD
-
Method: GetArraySize
Summary: Gets the size of the array of a primitive, specified by its
name, nested one level inside of the current set, without
changing which set is the current set
Description: If the specified primitive is not an array, this results
in a terminal error
Return: The size of the array of a primitive, specified by its name, nested
one level inside of the current set
-
char* GetDefine |
(
char* name
,
int Index = - 1
) ; |
Method: GetDefine
Summary: Gets the value of a define primitive, specified by its
name, nested one level inside of the current set, without
changing which set is the current set
Description: If the specified primitive is not a define, this results
in a terminal error
Return: The value of a define primitive (the string following the define
name), specified by the define name, nested one level inside of the
current set
-
int GetEnum |
(
char* name
,
int Index = - 1
) ; |
Method: GetEnum
Summary: Gets the value of an enumeration primitive, specified by
its name, nested one level inside of the current set,
without changing which set is the current set
Description: If the specified primitive is not an enumeration, this results
in a terminal error
Return: The value of an enumeration primitive (the integral order of this
primitve starting at 0 in the current set of enumerations),
specified by its name, nested one level inside of the current set
-
INTERNAL METHOD
-
INTERNAL METHOD
-
double GetFloat |
(
char* name
,
int Index = - 1
) ; |
Method: GetFloat
Summary: Gets the value of a float (floating point) primitive,
specified by its name, nested one level inside of the
current set, without changing which set is the current set
Description: If the specified primitive is not a float, this results
in a terminal error
Return: The value of a float primitive, specified by its name, nested
one level inside of the current set
-
int GetInt |
(
char* name
,
int Index = - 1
) ; |
Method: GetInt
Summary: Gets the value of an integer primitive, specified by its
name, nested one level inside of the current set, without
changing which set is the current set
Description: If the specified primitive is not an integer, this results
in a terminal error
Return: The value of an integer primitive, specified by its name, nested
one level inside of the current set
-
Method: GetLogical
Summary: Gets the value of a logical primitive, specified by its
name, nested one level inside of the current set, without
changing which set is the current set
Description: If the specified primitive is not a logical, this results
in a terminal error
Return: The value of a logical primitive (0 for f or false, 1 for t or
true), specified by its name, nested one level inside of the
current set
-
INTERNAL METHOD
-
INTERNAL METHOD
-
INTERNAL METHOD
-
INTERNAL METHOD
-
INTERNAL METHOD
-
INTERNAL METHOD
-
INTERNAL METHOD
-
INTERNAL METHOD
-
Method: GetNumSetsInGroup
Summary: Get the number of sets belonging to the specified set group
nested one level in from the current set. This method does
not change which set is the current set.
Description: This method is normally used just before looping
through a set group so as to know how many sets to loop
through.
Return: The number of sets belonging to a reference name group nested one
level in from the current set
- groupName
- Group name of the set group of interest.
-
INTERNAL METHOD
-
Method: GetSetName
Summary: Gets the name of the current set
Description:
Return: The name of the current set
-
char* GetString |
(
char* name
,
int Index = - 1
) ; |
Method: GetString
Summary: Gets the value of a string primitive, specified by its
name, nested one level inside of the current set, without
changing which set is the current set
Description: If the specified primitive is not a string, this results
in a terminal error
Return: The value of a string primitive, specified by its name, nested
one level inside of the current set
-
INTERNAL METHOD
-
void* GoTo |
(
char* FirstName
,
...
) ; |
INTERNAL METHOD
-
INTERNAL METHOD
-
INTERNAL METHOD
-
INTERNAL METHOD
-
INTERNAL METHOD
-
INTERNAL METHOD
-
void MoveIn |
(
char* setName
) ; |
Method: MoveIn
Summary: Move into a top-level set (if not currently in a set) or
into a set nested in the current set. The set moved to is
called the current set, in which subsequant data extraction
is possible.
Description: MoveIn () is used to move to a set (with or without a
reference name or the keyword "reference") that is
nested in the current set (ie, the set to which the
user last moved). MoveIn () must be called at least
once (ie, to move to a top-level set and then move into
nested sets as desired) before any data extraction is
possible. MoveIn (), MoveOut (), MoveOutCompletely (),
MoveToFirstSetInGroup (), and MoveToNextSetInGroup () are
the five recommended methods to use for navigating
through the nested data structures in a *.par file.
Return: None
- setName
- The name of the set into which to move.
-
void MoveOut |
(
int numLevels = 1
) ; |
Method: MoveOut
Summary: Move out of a set to the set in which it is nested,
optionally multiple times
Description: MoveOut () changes the current set to be the set in
which the cureent set is nested. MoveIn (), MoveOut (),
MoveOutCompletely (), MoveToFirstSetInGroup (), and
MoveToNextSetInGroup () are the five recommended methods
to use for navigating through the nested data
structures in a *.par file.
Return: None
- numLevels
- The number of MoveOuts to execute.
-
Method: MoveOutCompletely
Summary: Jump out of the arbitrarily deeply nested current set, such
that the next call to MoveIn () moves to a top-level set.
Description: MoveOutCompletely () is equivalent to calling MoveOut
() multiple times until no longer in any sets (ie,
reseting the DATA_PARSER to the initial condition where
there is no current set). Thus, the user must call
MoveIn () with a top-level set as the argument just
after calling MoveOutCompletely () in order to do any
subsequent data extraction. MoveIn (), MoveOut (),
MoveOutCompletely (), MoveToFirstSetInGroup (), and
MoveToNextSetInGroup () are the five recommended methods
to use for navigating through the nested data
structures in a *.par file.
Return: None
-
Method: MoveToFirstSetInGroup
Summary: Moves into the first set of the specified set group. The
set to which the DATA_PARSER moves becomes the current set.
Description: If the first set in the specified set group is an
inline set, the DATA_PARSER will move one nested level
into that set, which becomes the current set. On the
other hand, if the first set in the specified set group
is a reference, the DATA_PARSER will actually move to
the top-level set referenced and make that set the
current set. MoveIn (), MoveOut (), MoveOutCompletely
(), MoveToFirstSetInGroup (), and MoveToNextSetInGroup
() are the five recommended methods to use for
navigating through the nested data structures in a
.par file.
Return: None
- groupName
- Group name of the set group of interest.
-
Method: MoveToNextSetInGroup
Summary: Moves into the next set of the set group specified by the
last call to MoveToFirstSetInGroup () at this level in the
nested structure. The set to which the DATA_PARSER moves
becomes the current set.
Description: If the next set in the set group specified by the last
call to MoveToFirstSetInGroup () is an inline set, the
DATA_PARSER will move out of the current set and then
into that inline set, which becomes the current set. On
the other hand, if the next set is a reference, the
DATA_PARSER will move out of the current set and then
actually move to the top-level set referenced and make
that set the current set. MoveIn (), MoveOut (),
MoveOutCompletely (), MoveToFirstSetInGroup (), and
MoveToNextSetInGroup () are the five recommended
methods to use for navigating through the nested data
structures in a *.par file.
Return: None
-
INTERNAL METHOD
-
void print |
(
ostream& out = cout
) ; |
Method: print
Summary: Print this DATA_PARSER's *.par file with appropriate indentation
Description:
Return: None
Private Interface
Private Data
DEFINE_DATA_TYPE* DefPtr;
-
char* FileName;
-
BASE_DATA_TYPE* GoToBDT;
- Current Mark.
C_QUEUE Qatoms;
-
C_QUEUE Qtypes;
-
C_QUEUE markStack;
-
void* setMark;
- Current set in which references are being looped.
char setMarkRefName [ 128 ];
- Current set in which references are being looped Current set's reference name being looped.
#include "StopWatch.H"
Class: STOPWATCH
Summary: Class for single and/or cumulative timing of any time intervals in
the simulation. Timing always includes both wall (actual/real
total) time and CPU (computer processing) time.
Description: Use objects of this class to time any aspects of the
simulation. Objects can be named during construction, reset, and
repeatedly started and stopped. If not reset, they only keep
track of cumulative time. Either CPU or wall time can be set as
the default of what is returned and/or printed, but STOPWATCHes
always keep track of both. Thus the flag for CPU or wall time
returning and printing can be changed at any time ad infinitum
during the cumulative timing.
Public Interface
-
Constructor:
Summary: Initializes the object and sets the name of the stopwatch (can be
NULL)
Description:
- n
- IN: name of stopwatch (can be NULL).
-
-
-
Method: Reset
Summary: Reset cumulative wall time and and CPU time
Description: The first time StartTimer() and StopTimer() are called after
object construction or after calling Reset(), this class begins
cumulative timing from zero for both wall clock timing and CPU
timing. Otherwise it continues accumulating both wall clock and
CPU time from past StartTimer()/StopTimer intervals. Regardless
of the Clock Flag, the class cumulatively stores both types of
time.
Return: None
-
Method: StartTimer
Summary: Begin timing a new time interval for either wall time or CPU time,
and continue cumulative wall time and CPU time
Description: Objects of this type will return the time interval beginning
with this call when the next StopTimer() is called. The time
value returned depends on the setting of the Clock Flag (the
default is wall time) when StopTimer is called, which can be set
before or after calling StartTimer() with the methods
UseWallTime() and UseClockTime(). The first time this method is
called after object construction or after calling Reset(), this
method begins cumulative timing from zero for both wall clock
timing and CPU timing. Otherwise it continues accumulating both
wall clock and CPU time from past StartTimer()/StopTimer
intervals. Regardless of the Clock Flag, the class cumulatively
stores both types of time.
Return: None
-
Method: StopTimer
Summary: Stop timing the interval since the last StartTimer() call, stop
cumulative wall time and CPU time, and return the time value of the
time interval since the last StartTimer() call
Description: This returns the time interval beginning with the most recent
StartTimer() call. The time value returned depends on the
current setting of the Clock Flag (the default is wall time),
which must be set previously, but can be set before or after the
most recent StartTimer() call with the methods UseWallTime() and
UseClockTime(). The first time StartTimer() and StopTimer() are
called after object construction or after calling Reset(), this
class begins cumulative timing from zero for both wall clock
timing and CPU timing. Otherwise it continues accumulating both
wall clock and CPU time from past StartTimer()/StopTimer
intervals. Regardless of the Clock Flag, the class cumulatively
stores both types of time.
Return: Either wall time or CPU time in seconds, depending on the Clock Flag,
which is set by using either UseWallTime() or UseClockTime()
-
Method: UseClockTime
Summary:
Description:
Return: None
-
Method: UseWallTime
Summary:
Description:
Return: None
-
Method: get_CumulativeClockTime
Summary: Get cumulative CPU time
Description: The first time StartTimer() and StopTimer() are called after
object construction or after calling Reset(), this class begins
cumulative timing from zero for both wall clock timing and CPU
timing. Otherwise it continues accumulating both wall clock and
CPU time from past StartTimer()/StopTimer intervals. Regardless
of the Clock Flag, the class cumulatively stores both types of
time.
Return: Cumulative CPU time in seconds
-
Method: get_CumulativeTime
Summary: Get cumulative wall time
Description: The first time StartTimer() and StopTimer() are called after
object construction or after calling Reset(), this class begins
cumulative timing from zero for both wall clock timing and CPU
timing. Otherwise it continues accumulating both wall clock and
CPU time from past StartTimer()/StopTimer intervals. Regardless
of the Clock Flag, the class cumulatively stores both types of
time.
Return: Cumulative wall time in seconds
-
Method: get_name
Summary: Get the name of this Stopwatch
Description: This is set in the constructor of this class
Return: The name of this Stopwatch
-
Overloaded Method: print
Summary: Print the name of this stopwatch and the cumulative wall and CPU
times to cout
Description:
Return: None
-
void print |
(
ostream& out
) const; |
Overloaded Method: print
Summary: Print the name of this stopwatch and the cumulative wall and CPU
times
Description:
Return: None
- out
- IN: ostream to which to print.
Private Interface
Private Data
int ClockFlag;
-
double CumulativeClockTime;
-
double CumulativeTime;
-
clock_t StartClockTime;
-
double StartTime;
-
char* name;
-
Metric Summary for NON-ROLLBACKABLE CONTAINERS---------------------------+
Total number of classes | 6 | 23% of total |
Total number of statements | 70 | 12% of total |
Total number of free standing functions | 3 | 13% of total |
Average statements per class | 11 | -44% from average |
Average McCabe complexity per class | 9 | -38% from average |
Average number of public member functions per class | 16 | -28% from average |
Average number of protected member functions per class | 0 | -100% from average |
Average number of parameters per function | 0.6 | -29% from average |
Average number of statements per function | 1.3 | -14% from average |
Percent of functions documented | 91% | 10% from average |
#include "dbl_item.H"
Class: C_DBL_ITEM
Summary: Base class for classes whose objects can be non-rollbackably
inserted into doubly linked list data structures of type
C_DBL_QUEUE
Description: Classes must inherit from this class to be inserted into
C_DBL_QUEUEs. This class does not have any rollback support, and
is thus simply a generic doubly-linked queue item that can be
sorted according to simulated time tags by a C_DBL_QUEUE. For
doubly-linked rollbackable queues, use C_SQ_ITEMs and
C_XQUEUEs. Objects of this type can only be inserted into
C_DBL_QUEUEs (ie, not C_QUEUEs or C_XQUEUEs). They can also be
used in a C_DBL_QUEUE used as a stack. That is, when
consistantly popping from the top of the queue, pushing can be
to the top or the bottom of the queue. When consistantly pushing
to the top, the C_QUEUE acts as a stack. When consistantly
pushing to the bottom, the C_QUEUE acts as a queue. Pushing
effects are vice-versa when consistantly popping from the bottom
(rather than the top) of the queue. Sorting and inserting
operations always put the low time value on top so that
consecutive pops off the top of the sorted queue or stack occurs
in simulated time order.
Public Interface
-
-
-
Method: get_id
Summary: Gets the ID of this item
Description:
Return: The ID of this item
-
Method: get_next
Summary: Gets the forward link from this C_DBL_ITEM to the next C_DBL_ITEM
Description: Use this to get the C_DBL_ITEM linked as the next C_DBL_ITEM in
the doubly-linked C_DBL_QUEUE data structure in which this
C_DBL_ITEM is contained
Return: The C_DBL_ITEM forwardly linked from this C_DBL_ITEM
-
Method: get_previous
Summary: Gets the backward link from this C_DBL_ITEM to the previous
C_DBL_ITEM
Description: Use this to get the C_DBL_ITEM linked as the previous C_DBL_ITEM
in the doubly-linked C_DBL_QUEUE data structure in which this
C_DBL_ITEM is contained
Return: The C_DBL_ITEM backwardly linked from this C_DBL_ITEM
-
Method: get_ptr
Summary: Gets the pointer of this item to its data
Description:
Return: The pointer to this item's data
-
Method: get_valu
Summary: Gets the simulated time of this item
Description:
Return: The simulated time of this item
-
Virtual Method: print
Summary: By default, this method prints the ID and simulation time to stderr,
but is user-overridable.
Description:
Return: None
-
Method: set_id
Summary: Sets the ID of this item
Description:
Return: None
- i
- IN: the ID of this item.
-
INTERNAL METHOD
- nxt
- IN: C_ITEM to follow this one in the C_DBL_QUEUE this is currently contained in.
-
INTERNAL METHOD
- prv
- IN: C_ITEM to preceed this one in the C_DBL_QUEUE this is currently contained in.
-
Method: set_ptr
Summary: Sets the pointer of this item to its data
Description:
Return: None
- p
- IN: the pointer to this item's data.
-
Method: set_valu
Summary: Sets the simulated time of this item
Description:
Return: None
- v
- The simulated time of this item.
Protected Interface
Protected Data
int id;
- Id of the item.
void* ptr;
- Pointer to some data.
SIMTIME valu;
- Value of the item.
Private Interface
Private Data
C_DBL_ITEM* next;
- Link to next item.
C_DBL_ITEM* previous;
- Link to previous item.
#include "dbl_queue.H"
Class: C_DBL_QUEUE
Summary: Doubly-linked list non-rollbackable data structure
Description: This class is simply a non-rollbackable generic dounly-linked
queue that sorts C_DBL_ITEMs according to simulated time
tags. It can also be used as a stack. That is, when consistantly
popping from the top of the queue, pushing can be to the top or
the bottom of the queue. When consistantly pushing to the top,
the C_DBL_QUEUE acts as a stack. When consistantly pushing to
the bottom, the C_DBL_QUEUE acts as a queue. Pushing effects are
vice-versa when consistantly popping from the bottom (rather
than the top) of the queue (for C_XQUEUEs or C_DBL_QUEUEs
only). Sorting and inserting operations always put the low time
value on top so that consecutive pops off the top of the sorted
queue or stack occurs in simulated time order.
Public Interface
-
-
-
INTERNAL METHODMethod: check_order
Summary: Checks if the items are in time order, from earliest to latestS
Description:
Return: None
-
Method: get_bot
Summary: Get a pointer to the item at the bottom of the queue without
removing it from the queue.
Description:
Return: A pointer to the item at the bottom of the queue
-
Method: get_length
Summary: Get the number of items in the queue
Description:
Return: The number of items in the queue
-
Method: get_top
Summary: Get a pointer to the item at the top of the queue without removing
it from the queue.
Description:
Return: A pointer to the item at the top of the queue
-
Method: insert
Summary: Inserts a specified item into the queue in time order (earlier time
on top)
Description:
Return: None
- dbl_item
- IN: specified item to insert.
-
Method: pop_bot
Summary: Pops a specified item off of (ie, removes a specified item from) the
bottom of the queue and returns it
Description:
Return: Item that has been popped off of (removed from) the bottom of the
queue
-
Method: pop_top
Summary: Pops a specified item off of (ie, removes a specified item from) the
top of the queue and returns it
Description:
Return: Item that has been popped off of (removed from) the top of the queue
-
Method: push_bot
Summary: Pushes a specified item onto (ie, inserts a specified item at) the
bottom of the queue
Description:
Return: None
- dbl_item
- IN: specified item to insert.
-
Method: push_top
Summary: Pushes a specified item onto (ie, inserts a specified item at) the
top of the queue
Description: This method moves the top pointer in this queue to the specified
item, which then points to the old top item
Return: None
- dbl_item
- IN: specified item to insert.
-
Method: remove
Summary: Remove (delete) an item from the queue
Description:
Return: None
- dbl_item
- IN: item to remove from the queue.
Private Interface
Private Data
C_DBL_ITEM* bot;
- Pointer to the bottom of the queue.
int length;
- Length of the queue.
C_DBL_ITEM* top;
- Pointer to the top of the queue.
#include "qitem.H"
INTERNAL METHODSummary: Dummy class that puts the V table at the top of item objects
Description:
Public Interface
-
-
Private Interface
Private Data
NET_INT dummy_v_allign;
-
#include "hash.H"
Class: C_HASH
Summary: An array of queues with array like access to items
Description:
Public Interface
-
Constructor Method:
Summary: Constructs a C_HASH with a hash array of specified length
Description:
- n
- Length of hash array.
-
-
-
Method: add
Summary: Add a specified C_ITEM to the hash table
Description: Push specified item to the bottom of the appropriate queue in
the hash array
Return: None
- item
- C_ITEM to add.
-
Method: combine
Summary: Concatonate each queue in this hash array into one queue, leaving
the original hash table intact
Description: The resulting single queue can then be retrieved with the method
get_all () and printed with printq ().
Return: None
-
Method: dehash
Summary:
Description:
Return: None
-
Method: dehash
Summary:
Description:
Return: C_ITEM
-
Method: get
Summary: Return the C_ITEM in this hash table specified by item's name
Description: Gets the item from the appropriate queue in the hash array
Return: The C_ITEM in this hash table specified by item's name
- name
- Name of C_ITEM to get.
-
Method: get
Summary: Return the C_ITEM in this hash table specified by item's ID
Description: Gets the item from the appropriate queue in the hash array
Return: The C_ITEM in this hash table specified by item's ID
- hid
- ID of C_ITEM to get.
-
Method: get_all
Summary: Get the combined queue generated by the last call to combine ()
Description:
Return: The combined queue generated by the last call to combine ()
-
Method: get_hashid
Summary: Return a C_ITEM's ID in this hash table specified by its name
Description:
Return: The C_ITEM's ID in this hash table specified by its name
- name
- Name of C_ITEM from whom to get ID.
-
Method: get_nitems
Summary: Get the number of C_ITEMs in this hash table
Description:
Return: The number of C_ITEMs in this hash table
-
Method: get_size
Summary: Get the number of queues in this hash array
Description:
Return: The number of queues in this hash array
-
Method: printh
Summary: Print each C_ITEM in the hash table
Description: This prints the hash table by calling the virtual function print
() on all of the C_ITEMs in the hash table. Unlike printq (),
this method does not rely on first calling combine ().
Return: None
-
Method: printq
Summary: Print each C_ITEM in the combined hash table
Description: Unlike printh (), which simply prints the hash table, this
method relies on first calling combine () which concatonates the
hash array into one combined queue. The resulting combined queue
is printed with this method by calling the virtual function
print () on all of the C_ITEMs in the combined queue.
Return: None
-
Method: remove
Summary: Remove (delete) the specified item from this hash table
Description:
Return: None
- item
- C_ITEM to remove.
-
Method: remove
Summary: Remove (delete) an item from this hash table specified by its ID
Description:
Return: None
- id
- ID of C_ITEM to remove.
-
Method: reset
Summary: Clear the hash table
Description: Clear (delete) every queue in the hash array, then set length of
the hash array to zero
Return: None
Protected Interface
Protected Data
int nitems;
- Total number of items in the hash.
C_QUEUE* q;
- Array of queues (dimension size).
C_QUEUE* qall;
- A queue of concatonated hash queues.
int size;
- Size of queue array.
#include "qitem.H"
Class: C_ITEM
Summary: Base class for classes whose objects can be non-rollbackably
inserted into singly linked list data structures of type C_QUEUE
Description: Classes must inherit from this class to be inserted into
C_QUEUEs. This class does not have any rollback support, and is
thus simply a generic queue item that can be sorted according to
simulated time tags by a C_QUEUE. Objects of this type can only
be inserted into C_QUEUEs (ie, not C_XQUEUEs, which require
rollback support). They can also be used in a C_QUEUE used as a
stack. That is, popping must always be from the top of the queue
(since it is singly linked) but pushing can be to the top or the
bottom of the queue. When consistantly pushing to the top, the
C_QUEUE acts as a stack. When consistantly pushing to the
bottom, the C_QUEUE acts as a queue. Sorting and inserting
operations always put the low time value on top so that popping
off the sorted queue or stack occurs in simulated time order.
Public Interface
-
-
-
Virtual Destructor: ~C_ITEM
Summary: By default, this destructor does nothing, but is user-overridable
Description:
-
Method: GetDoubleValue
Summary: Gets the simulated time tag for this C_ITEM without returning the
priority fields
Description:
Return: The simulated time tag (as a double without returning the priority
fields)
-
Virtual Method: GetName
Summary: By default, this is not implemented, but is user-overridable, and is
intended to return the name of this C_ITEM.
Description:
Return: A character pointer intended to return the name of this C_ITEM
-
Method: SetDoubleValue
Summary: Sets the simulated time tag for this C_ITEM without setting or
affecting the SIMTIME priority fields
Description:
Return: None
-
Virtual Method: compare
Summary: By default, this method determines whether the IDs of this and
another C_ITEM are the same. It is user-overridable.
Description:
Return: Flag for whether the IDs of this and the passed-in C_ITEM are the
same
- it
- IN: the C_ITEM with which to compare.
-
Virtual Method: copy
Summary: By default, this is not implemented, but is user overridable.
Description:
Return: A C_ITEM
-
INTERNAL METHOD
-
Method: get_id
Summary: Get the ID of this C_ITEM
Description:
Return: The ID of this C_ITEM
-
Method: get_link
Summary: Gets the link for this C_ITEM (ie, the link in the singly-linked
C_QUEUE data structure)
Description:
Return: The link for this C_ITEM (ie, the link in the singly-linke C_QUEUE
data structure)
-
Method: get_time_tag
Summary: Gets the simulated time tag for this C_ITEM
Description:
Return: The simulated time tag (SIMTIME)
-
Virtual Method: print
Summary: By default, this method prints the ID and simulation time to stderr,
but is user-overridable.
Description:
Return: None
-
Virtual Method: printfile
Summary: By default, this is not implemented, but is user-overridable, and is
intended to print statistics about this C_ITEM to a file.
Description:
Return: None
-
- IN: file to print to.
-
Virtual Method: printstream
Summary: By default, this method prints the ID and simulation time to an
ostream object, but is user-overridable.
Description:
Return: None
- out
- IN: ostream object to print to.
-
INTERNAL METHOD
- lnk
- IN: next C_ITEM in the C_QUEUE.
-
INTERNAL METHOD
-
Method: set_id
Summary: Set the ID of this C_ITEM
Description:
Return: None
-
INTERNAL METHOD
- lnk
- IN: next C_ITEM in the C_QUEUE.
-
Method: set_time_tag
Summary: Sets the simulated time tag for this C_ITEM
Description:
Return: None
- t
- IN: simulated time tag.
-
Overloaded Method: set_time_tag
Summary: Sets the simulated time tag for this C_ITEM, setting the SIMTIME
priority fields automatically to zero.
Description:
Return: None
- t
- IN: time tag.
-
Overloaded Method: set_time_tag
Summary: Sets the simulated time tag for this C_ITEM, setting the first
SIMTIME priority field to a passed-in value, and setting the second
priority field automatically to zero.
Description:
Return: None
- t
- IN: time tag.
- p1
- IN: first priority field.
-
Overloaded Method: set_time_tag
Summary: Sets the simulated time tag for this C_ITEM, including both priority
fields
Description:
Return: None
- t
- IN: time tag.
- p1
- IN: first priority field.
- p2
- IN: second priority field.
Public Data
NET_INT freeid;
- Free list id.
NET_INT id;
- Id.
NET_INT item_allign;
-
C_ITEM* link;
-
SIMTIME time_tag;
- Time tag of item for sorting.
#include "queue.H"
Class: C_QUEUE
Summary: Singly linked list non-rollbackable data structure
Description: This class does not have any rollback support, and is thus
simply a generic queue that sorts C_ITEMs according to simulated
time tags. It can also be used as a stack. That is, popping must
always be from the top of the queue (since it is singly linked)
but pushing can be to the top or the bottom of the queue. When
consistantly pushing to the top, this data structure acts as a
stack. When consistantly pushing to the bottom, it acts as a
queue. Sorting and inserting always put the low time value on
top so that popping off the sorted queue or stack occurs in
simulated time order.
Public Interface
-
-
-
Method: clear
Summary: Clear this queue and delete all the items
Description: Sets top and bottom of this queue to NULL, and number of items
to zero
Return: None
-
Method: concat
Summary: Concatenate a specified queue with this queue, and reset the
specified queue
Description:
Return: None
- q
- IN: specified queue to concatenate with this queue.
-
Method: copy
Summary: Copy this queue
Description:
Return: A copy of this queue
-
Overloaded Method: deque
Summary: Remove (but don't delete) an item from the queue
Description:
Return: None
- item
- IN: item to remove.
-
Overloaded Method: deque
Summary: Remove (but don't delete) an item from the queue
Description:
Return: A removed (but not deleted) item from the queue
- rid
- IN: ID of item to remove.
-
Method: fast_pop_top
Summary: Pops a specified item off of (ie, removes a specified item from) the
top of the queue and returns it, but loses track of the number of
items in the queue
Description: This method has undefined (erroneous) behavior when the queue is
empty or has only one item in it. It also does not decrement the
number of items. If either of these issues are (or potentially
are) a problem, use pop_top, which is a slower but safe routine,
instead.
Return: Item that has been popped off of (removed from) the top of the queue
-
Method: get_bot (same as pbot)
Summary: Get a pointer to the item at the bottom of the queue without
removing it from the queue.
Description:
Return: A pointer to the item at the bottom of the queue
-
Method: get_item
Summary: Get a pointer to the item with a specified ID
Description:
Return: A pointer to the item with a specified ID
- id
- IN: ID of item.
-
Method: get_length (same as length)
Summary: Get the number of items in the queue
Description:
Return: The number of items in the queue
-
Method: get_top (same as ptop)
Summary: Get a pointer to the item at the top of the queue without removing
it from the queue.
Description:
Return: A pointer to the item at the top of the queue
-
Method: init
Summary: Initialize the queue object
Description: This should be called initially or just after clearing the
queue. Otherwise, calling this method will permanently lose the
current information in the queue and create memory leaks.
Return: None
- t
- IN: top of the queue.
- b
- IN: bottom of the queue.
- len
- IN: number of items in the queue.
-
Method: insert (same as insert_after)
Summary: Insert a specified item into this queue, with the item having the
lower simulated time tag on top
Description:
Return: None
- item
- IN: specified item to insert into this queue.
-
Method: insert_after (same as insert)
Summary: Insert an item into this queue, with the item having the lower
simulated time tag on top
Description:
Return: None
- item
- IN: specified item to insert into this queue.
-
Method: join
Summary: Concatenate a specified queue to this queue, but do not reset
the specified queue
Description:
Return: None
- q
- IN: specified queue to concatenate with this queue.
-
Method: length (same as get_length)
Summary: Get the number of items in the queue
Description:
Return: The number of items in the queue
-
Method: merge
Summary: Merge a specified queue into this queue in simulated time order
Description:
Return: None
- q
- IN: specified queue to merge with this queue.
-
Method: next
Summary: Get a pointer to the item in the queue immediately following (ie
below) a specified item without removing it from the queue
Description:
Return: A pointer to the item in the queue immediately following (ie
below) a specified item without removing it from the queue
- item
- IN: specified item after which the requested item lies.
-
Method: pbot (same as get_bot)
Summary: Get a pointer to the item at the bottom of the queue without
removing it from the queue.
Description:
Return: A pointer to the item at the bottom of the queue
-
Method: pop_top
Summary: Pops a specified item off of (ie, removes a specified item from) the
top of the queue and returns it
Description:
Return: Item that has been popped off of (removed from) the top of the queue
-
Method: print
Summary: Print the items in this queue
Description:
Return: None
-
Method: printstream
Summary: print the items in this queue using stream io
Description:
Return: None
- out
- IN: the ostream to which to print.
-
Method: ptop (same as get_top)
Summary: Get a pointer to the item at the top of the queue without removing
it from the queue.
Description:
Return: A pointer to the item at the top of the queue
-
Method: push_bot
Summary: Pushes a specified item onto (ie, inserts a specified item at) the
bottom of the queue
Description:
Return: None
- item
- IN: specified item to insert.
-
Method: push_top
Summary: Pushes a specified item onto (ie, inserts a specified item at) the
top of the queue
Description: This method moves the top pointer in this queue to the specified
item, which then points to the old top item
Return: None
- item
- IN: specified item to insert.
-
Overloaded Method: remove
Summary: Remove (delete) an item from the queue
Description:
Return: None
- item
- IN: item to remove.
-
Overloaded Method: remove
Summary: Remove (delete) an item from the queue
Description:
Return: None
- id
- IN: ID of item to remove.
-
Method: reset
Summary: Clear this queue without deleting the items
Description: Sets top and bottom of this queue to NULL, and number of items
to zero
Return: None
-
Method: set_bot
Summary: Set the bottom of the queue to point to a specified item
Description: This should be called initially or just after clearing the
queue. Otherwise, calling this method will permanently lose the
current information in the queue and create memory leaks.
Return: None
-
Method: set_length
Summary: Set the number of items in the queue (GET RID OF!)
Description:
Return: None
-
- IN: number of items in the queue.
-
Method: sort
Summary: Sort the queue in time order
Description: If the number of items is 15 or less, this method uses insertion
sort. Otherwise, it recursively divides the items into pairs of
two halves until the number of items in each resulting half is
15 or less. These are sorted with insertion sort. Once each each
pair has two sorted halves, the two halves are merged into one
sorted temporary queue. Finally, it recursively merges all
sorted temporary queues into the final sorted queue.
Return: None
Protected Interface
Protected Data
C_ITEM* bot;
-
static int cutoff;
- Cutoff number for sorting.
int n_items;
-
int queue_allign1;
-
int queue_allign2;
-
int queue_allign3;
-
C_ITEM* top;
-
void RB_DELETE_SINGLE_C_ITEM(C_ITEM* obj
) ;
|
|
void delete_single_C_ITEM(void* v
) ;
|
|
Metric Summary for ROLLBACKABLE CONTAINERS------------------------------------+
Total number of classes | 3 | 11% of total |
Total number of statements | 35 | 6% of total |
Total number of free standing functions | 9 | 39% of total |
Average statements per class | 7 | -62% from average |
Average McCabe complexity per class | 6 | -58% from average |
Average number of public member functions per class | 13 | -39% from average |
Average number of protected member functions per class | 0 | -100% from average |
Average number of parameters per function | 0.5 | -36% from average |
Average number of statements per function | 1.3 | -14% from average |
Percent of functions documented | 78% | -6% from average |
#include "sq_item.H"
Class: C_SQ_ITEM.
Summary: Base class for classes whose objects can be rollbackably inserted
into doubly-linked list data structures of type C_XQUEUE, or
non-rollbackably inserted into singly-linked list data structures of
type C_QUEUE
Description: Classes must inherit from this class to be inserted into
C_XQUEUEs or C_QUEUEs. This class is simply a generic queue item
that can be sorted according to simulated time tags by a
C_XQUEUE (doubly-linked) or C_QUEUE (singly-linked). All
operations on a C_SQ_ITEM in or by a C_XQUEUE are rollbackable,
while all operations on a C_SQ_ITEM in or by a C_QUEUE are
non-rollbackable. They can also be used in a C_XQUEUE or a
C_QUEUE used as a stack. That is, when consistantly popping from
the top of the queue (which is the only way to pop in a C_QUEUE,
since it is singly-linked), pushing can be to the top or the
bottom of the queue. When consistantly pushing to the top, the
C_XQUEUE or C_QUEUE acts as a stack. When consistantly pushing
to the bottom, the C_XQUEUE or C_QUEUE acts as a queue. Pushing
effects are vice-versa when consistantly popping from the bottom
(rather than the top) of the queue (for C_XQUEUEs or
C_DBL_QUEUEs only). Sorting and inserting operations always put
the low time value on top so that consecutive pops off the top
of the sorted queue or stack occurs in simulated time order.
Public Interface
-
-
-
Method: get_backlink
Summary: Gets the back link for this C_ITEM (ie, the link to the previous
item in the doubly-linked C_XQUEUE data structure)
Description:
Return: The back link for this C_ITEM (ie, the link to the previous item in
the doubly-linked C_XQUEUE data structure)
-
INTERNAL METHOD
-
INTERNAL METHOD
-
INTERNAL METHOD
-
INTERNAL METHOD
-
INTERNAL METHOD
-
INTERNAL METHOD
-
INTERNAL METHOD
Public Data
C_SQ_ITEM* backlink;
-
int processed;
-
C_QUEUE queue;
- JB: used for rqueues.
NET_INT sq_item_allign;
-
#include "xhash.H"
Public Interface
-
Constructor Method:
Summary: Constructs a C_XHASH with a hash array of specified length
Description:
- n
- Length of hash array.
-
Method: add
Summary: Add a specified C_SQ_ITEM to the hash table
Description: Push specified item to the bottom of the appropriate queue in
the hash array
Return: None
- item
- C_SQ_ITEM to add.
-
Method: combine
Summary: Concatonate each queue in this hash array into one queue, leaving
the original hash table intact
Description: The resulting single queue can then be retrieved with the method
get_all () and printed with printq ().
Return: None
-
INTERNAL METHOD
- x_item
- IN: C_SQ_ITEM to exchange.
-
Overloaded Method: find
Summary: Return the C_SQ_ITEM in this hash table specified by item's name
Description: Gets the item from the appropriate queue in the hash array
Return: The C_SQ_ITEM in this hash table specified by item's name
-
Overloaded Method: find
Summary: Return the C_SQ_ITEM in this hash table specified by item's ID
Description: Gets the item from the appropriate queue in the hash array
Return: The C_SQ_ITEM in this hash table specified by item's ID
- hid
- ID of item to find.
-
Method: get_all
Summary: Get the combined queue generated by the last call to combine ()
Description:
Return: The combined queue generated by the last call to combine ()
-
Method: get_hashid
Summary: Passes in the name that is used for hashing and returns the hash
id that is used for the array index.
Return: The hash id that is used for the array index
-
Method: get_length
Summary: Get the number of C_SQ_ITEMs in this hash table
Description:
Return: The number of C_SQ_ITEMs in this hash table
-
Method: get_size
Summary: Get the number of queues in this hash array
Description:
Return: The number of queues in this hash array
-
Method: printh
Summary: Print each C_SQ_ITEM in the hash table
Description: This prints the hash table by calling the virtual function print
() on all of the C_SQ_ITEMs in the hash table. Unlike printq (),
this method does not rely on first calling combine ().
Return: None
-
Method: printq
Summary: Print each C_SQ_ITEM in the combined hash table
Description: Unlike printh (), which simply prints the hash table, this
method relies on first calling combine () which concatonates the
hash array into one combined queue. The resulting combined queue
is printed with this method by calling the virtual function
print () on all of the C_SQ_ITEMs in the combined queue.
Return: None
-
Method: remove
Summary: Remove (but don't delete) the specified item from this hash table
Description:
Return: None
- item
- INOUT: C_SQ_ITEM to remove.
-
Method: remove
Summary: Remove (but don't delete) an item from this hash table specified
by its ID
Description:
Return: None
- id
- IN: ID of C_SQ_ITEM to remove.
-
Method: reset
Summary: Clear the hash table
Description: Clear (delete) every queue in the hash array, then set length of
the hash array to zero
Return: None
Protected Interface
Protected Data
int nitems;
- Total number of items in the xhash.
C_XQUEUE* q;
- Array of queues (dimension size).
C_XQUEUE* qall;
- A queue of concatonated xhash queues.
int size;
- Size of queue array.
#include "xqueue.H"
Class: C_XQUEUE
Summary: Doubly-linked list rollbackable data structure
Description: This class is simply a rollbackable generic queue that sorts
C_SQ_ITEMs according to simulated time tags. It can also be used
as a stack. That is, when consistantly popping from the top of
the queue, pushing can be to the top or the bottom of the
queue. When consistantly pushing to the top, the C_XQUEUE acts
as a stack. When consistantly pushing to the bottom, the
C_XQUEUE acts as a queue. Pushing effects are vice-versa when
consistantly popping from the bottom (rather than the top) of
the queue (for C_XQUEUEs or C_DBL_QUEUEs only). Sorting and
inserting operations always put the low time value on top so
that consecutive pops off the top of the sorted queue or stack
occurs in simulated time order.
Public Interface
-
-
-
INTERNAL METHODMethod: check_integrity
Summary: Make sure the variables of this class are consistent with one
another
Description:
Return: None
-
INTERNAL METHOD
-
Method: find
Summary: Find (without deleting) an item from the queue
Description:
Return: An item from the queue
- id
- IN: item ID to find from the queue.
-
Method: get_bot
Summary: Get a pointer to the item at the bottom of the queue without
removing it from the queue.
Description:
Return: A pointer to the item at the bottom of the queue
-
Method: get_length
Summary: Get the number of items in the queue
Description:
Return: The number of items in the queue
-
Method: get_top
Summary: Get a pointer to the item at the top of the queue without removing
it from the queue.
Description:
Return: A pointer to the item at the top of the queue
-
Method: join
Summary: Concatenate a specified queue to this queue, but do not reset
the specified queue
Description:
Return: None
- q
- IN: specified queue to concatenate with this queue.
-
Method: pop_bot
Summary: Pops a specified item off of (ie, removes a specified item from) the
bottom of the queue and returns it
Description:
Return: Item that has been popped off of (removed from) the bottom of the
queue
-
Method: pop_top
Summary: Pops a specified item off of (ie, removes a specified item from) the
top of the queue and returns it
Description:
Return: Item that has been popped off of (removed from) the top of the queue
-
Method: print
Summary: Print the items in this queue
Description:
Return: None
-
Method: push_bot
Summary: Pushes a specified item onto (ie, inserts a specified item at) the
bottom of the queue
Description:
Return: None
- x_item
- IN: specified item to insert.
-
Method: push_top
Summary: Pushes a specified item onto (ie, inserts a specified item at) the
top of the queue
Description: This method moves the top pointer in this queue to the specified
item, which then points to the old top item
Return: None
- x_item
- IN: specified item to insert.
-
Method: remove
Summary: Remove (but don't delete) an item from the queue
Description:
Return: None
- x_item
- INOUT: item to remove from the queue.
-
Method: reset
Summary: Clear this queue without deleting the items
Description: Sets top and bottom of this queue to NULL, and number of items
to zero
Return: None
-
Method: set_length
Summary: Set the number of items in the queue (GET RID OF!)
Description:
Return: None
Private Interface
Private Data
C_SQ_ITEM* bot;
-
int length;
-
C_SQ_ITEM* top;
-
int xqueue_allign1;
-
int xqueue_allign2;
-
int xqueue_allign3;
-
void RB_DELETE_ARRAY_C_SQ_ITEM(C_SQ_ITEM* obj
) ;
|
|
void RB_DELETE_SINGLE_C_SQ_ITEM(C_SQ_ITEM* obj
) ;
|
|
void RB_DELETE_SINGLE_C_XQUEUE(C_XQUEUE* obj
) ;
|
|
C_SQ_ITEM* RB_NEW_C_SQ_ITEM(size_t num_C_SQ_ITEM
) ;
|
|
void delete_C_SQ_ITEM_array(void* v
) ;
|
|
void delete_single_C_SQ_ITEM(void* v
) ;
|
|
void delete_single_C_XQUEUE(void* v
) ;
|
|