Table.cpp 2 KB
Newer Older
gsell's avatar
gsell committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
// ------------------------------------------------------------------------
// $RCSfile: Table.cpp,v $
// ------------------------------------------------------------------------
// $Revision: 1.2.4.1 $
// ------------------------------------------------------------------------
// Copyright: see Copyright.readme
// ------------------------------------------------------------------------
//
// Class: Table
//   This abstract base class defines the interface for the OPAL "TABLE"
//   command family.
//
// ------------------------------------------------------------------------
//
// $Date: 2002/12/09 15:06:07 $
// $Author: jsberg $
//
// ------------------------------------------------------------------------

#include "AbstractObjects/Table.h"
#include "AbstractObjects/OpalData.h"
#include "Utilities/OpalException.h"
#include "Utilities/Timer.h"
#include <iostream>


// Class Table
// ------------------------------------------------------------------------

Table::~Table() {
    // Remove pointer to "this" from table directory.
    if(! builtin) OpalData::getInstance()->unregisterTable(this);
}


36
bool Table::canReplaceBy(Object */*newObject*/) {
gsell's avatar
gsell committed
37 38 39 40
    return false;
}


Steve Russell's avatar
Steve Russell committed
41
Table *Table::find(const std::string &name) {
gsell's avatar
gsell committed
42 43 44 45 46 47 48 49
    Table *table = dynamic_cast<Table *>(OpalData::getInstance()->find(name));
    if(table == 0) {
        throw OpalException("Table::find()", "Table \"" + name + "\" not found.");
    }
    return table;
}


Steve Russell's avatar
Steve Russell committed
50
const std::string Table::getCategory() const {
gsell's avatar
gsell committed
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
    return "TABLE";
}


bool Table::shouldTrace() const {
    return true;

}

bool Table::shouldUpdate() const {
    return true;
}


void Table::invalidate() {
    if(dynamic) refill = true;
}


Table::Table(int size, const char *name, const char *help):
    Object(size, name, help), dynamic(false), refill(false) {
    // Do not link table exemplar.
}


Steve Russell's avatar
Steve Russell committed
76
Table::Table(const std::string &name, Table *parent):
gsell's avatar
gsell committed
77 78 79 80
    Object(name, parent), dynamic(true), refill(true) {
    // Link table to table directory.
    OpalData::getInstance()->registerTable(this);
}