Commit 90439974 authored by Will Schroeder's avatar Will Schroeder
Browse files

ENH: Added comments.

parent dd5b8cc1
......@@ -13,11 +13,11 @@ written consent of the authors.
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 1993, 1994
=========================================================================*/
//
// Common abstract class for Visualization Library. Maintains debug
// flag, reference counting, modified time, and other common
// functions/parameters.
//
// .NAME vlObject - abstract base class for many objects
// .SECTION Description
// vlObject is the base class for many objects in the visualization
// library. vlObject provides methods for reference counting, keeping
// track of modified time, debugging, and printing object.
#ifndef __vlObject_hh
#define __vlObject_hh
......@@ -28,43 +28,42 @@ Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 1993, 1994
#include "Indent.hh"
#include "PrintLst.hh"
//
// Common #defines / parameters
//
//
// Class definition
//
class vlObject
{
public:
vlObject();
virtual ~vlObject();
virtual char *GetClassName() {return "vlObject";};
// reference counting
void Register(vlObject* o);
void UnRegister(vlObject* o);
int GetRefCount() {return this->RefCount;};
// debugging
void DebugOn();
void DebugOff();
virtual unsigned long int GetMTime() {return this->MTime.GetMTime();};
int GetDebug();
// modified time
virtual unsigned long int GetMTime() { return this->MTime.GetMTime(); };
void Modified() {MTime.Modified();};
virtual char *GetClassName() {return "vlObject";};
// printing
virtual void PrintSelf(ostream& os, vlIndent indent);
void Print(ostream& os);
virtual void PrintHeader(ostream& os, vlIndent indent);
virtual void PrintSelf(ostream& os, vlIndent indent);
int ShouldIPrint(char *a) { return this->PrintList.ShouldIPrint(a);};
virtual void PrintTrailer(ostream& os, vlIndent indent);
void PrintWatchOn() {this->PrintList.ActiveOn();};
void PrintWatchOff() {this->PrintList.ActiveOff();};
protected:
int Debug; // Enable debug messages
int Debug; // Enable debug messages
vlTimeStamp MTime; // Keep track of modification time
private:
int RefCount; // Number of uses of this object by other objects
int RefCount; // Number of uses of this object by other objects
vlPrintList PrintList;
friend ostream& operator<<(ostream& os, vlObject& o);
......
......@@ -16,6 +16,8 @@ Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen 1993, 1994
#include "Object.hh"
// Description:
// Operator allows all subclasses of vlObject to be printed via <<.
ostream& operator<<(ostream& os, vlObject& o)
{
o.Print(os);
......@@ -40,12 +42,16 @@ vlObject::~vlObject()
vlDebugMacro(<< "Destructing!");
}
// Description:
// Increase the reference count (mark as used by another object).
void vlObject::Register(vlObject* o)
{
this->RefCount++;
vlDebugMacro(<< "Registered by " << o->GetClassName() << " (" << o << ")");
}
// Description:
// Decrease the reference count (release by another object).
void vlObject::UnRegister(vlObject* o)
{
vlDebugMacro(<< "UnRegistered by " << o->GetClassName() << " (" << 0 << ")");
......@@ -67,6 +73,9 @@ void vlObject::PrintHeader(ostream& os, vlIndent indent)
os << indent << this->GetClassName() << " (" << this << ")\n";
}
// Description:
// Chaining method to print object instance variables as well as
// superclasses.
void vlObject::PrintSelf(ostream& os, vlIndent indent)
{
if (this->ShouldIPrint(vlObject::GetClassName()))
......@@ -82,16 +91,22 @@ void vlObject::PrintTrailer(ostream& os, vlIndent indent)
os << indent << "\n";
}
// Description:
// Turn debug printout on.
void vlObject::DebugOn()
{
this->Debug = 1;
}
// Description:
// Turn debug printout off.
void vlObject::DebugOff()
{
this->Debug = 0;
}
// Description:
// Get the value of the debug flag.
int vlObject::GetDebug()
{
return this->Debug;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment