- Main Page
- Namespaces
- Classes
- Files
- Related Pages

# /Users/fpy/titan-1-5-MBARI/Mers/Utils/Lang/Object.cpp

    00001
    00002 //
    00003 // Copyright (c) 2004           Model-based Embedded and Robotic Systems Group
    00004 // All Rights Reserved          Massachusetts Institute of Technology
    00005 //
    00006 // This software is provided as is. Model-based Embedded and Robotic Systems
    00007 // (MERS) group does not assume any responsibility.
    00008 //
    00009 // Organization:        Model-based Embedded and Robotic Systems Group
    00010 //                                      Massachusetts Institute of Technology
    00011 //
    00013
    00014 #include "Object.h"
    00015 #include <cstdio>
    00016
    00017 #include <Mers/Utils/Exceptions/UnsupportedOperationException.h>
    00018
    00020
    00021
    00022 using Mers::Utils::Lang::Object;
    00023 using Mers::Utils::Exceptions::UnsupportedOperationException;
    00024 using std::ostream;
    00025
    00027 // Construction/Destruction
    00029
    00030 Object::Object(ObjectType myType) : objectType(myType)
    00031 {
    00032 }
    00033
    00035
    00036 Object::~Object()
    00037 {
    00038
    00039 }
    00040
    00042
    00043 char const * Object::objectTypeToString(Object::ObjectType objType)
    00044 {
    00045   // we may just want to do this as an array, but this switch statement is more reliable
    00046   // (it's more tollerant of reordering the object types in the header file)
    00047   switch(objType){
    00048   case BMAssignment:
    00049     return "Assignment";
    00050   case BMClause:
    00051     return "Clause";
    00052   case BMSentence:
    00053     return "Sentence";
    00054   case BMDomain:
    00055     return "Domain";
    00056   case BMVariable:
    00057     return "Variable";
    00058   case BMValue:
    00059     return "Value";
    00060   case BMVector:
    00061     return "Array";
    00062   case BMModel:
    00063     return "Model";
    00064   case oHCAAutomaton:
    00065     return "HCA Automaton";
    00066   case oHCATimeConstraint:
    00067     return "HCA Time Constraint";
    00068   case oHCATransition:
    00069     return "HCA Transition";
    00070   case oMarkedAutomaton:
    00071     return "Marked Automaton";
    00072   case oHCAFunctionCall:
    00073     return "HCA Function Call";
    00074   case oGIState:
    00075     return "GI State";
    00076   case oGIEntry:
    00077     return "GI Entry";
    00078   case oGoalInterpreter:
    00079     return "Goal Interpreter";
    00080   case oString:
    00081     return "String";
    00082   case oRTAPIMessage:
    00083     return "RTAPI Message";
    00084   case oCommandCallback:
    00085     return "Command Callback";
    00086   case oCCAAutomaton:
    00087     return "CCA Automaton";
    00088   case oCCAState:
    00089     return "CCA State";
    00090   case oCCATransition:
    00091     return "CCA Transition";
    00092   case oHaDMoReDependencyHyperedge:
    00093     return "HaDMoRe Dependency Hyperedge";
    00094   case oHaDMoReDependencyNode:
    00095     return "HaDMoRe Dependency Node";
    00096   case oDispatcherPair:
    00097     return "Dispatcher Pair";
    00098   default:
    00099     return "Unknown Object Type";
    00100   }
    00101 }
    00102
    00104
    00105 Object::ObjectType Object::getObjectType() const
    00106 {
    00107   return objectType;
    00108 }
    00109
    00111
    00112 Object * Object::duplicate() const
    00113 {
    00114   throw UnsupportedOperationException("duplicate()",__FILE__,__LINE__);
    00115 }
    00116
    00118
    00119 #ifndef EMBEDDED
    00120
    00121 namespace Mers {
    00122         namespace Utils {
    00123                 namespace Lang {
    00124
    00125 ostream & operator <<(ostream & out, Object const &other)
    00126 {
    00127   if(&other == NULL)
    00128     out << "NULL Object";
    00129   else
    00130     other.print(out);
    00131   return out;
    00132 }
    00133
    00135
    00136 ostream & operator <<(ostream & out, Object const * other)
    00137 {
    00138   if(other == NULL)
    00139     out << "NULL Object";
    00140   else
    00141     other->print(out);
    00142   return out;
    00143 }
    00144
    00145 }}}
    00146 #endif
    00147