Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members

ExceptionDef.cc

Go to the documentation of this file.
00001 //                            Package   : omniIFR
00002 //  ExceptionDef.cc           Created   : 2004/02/22
00003 //                            Author    : Alex Tingle
00004 //
00005 //    Copyright (C) 2004 Alex Tingle.
00006 //
00007 //    This file is part of the omniIFR application.
00008 //
00009 //    omniIFR is free software; you can redistribute it and/or
00010 //    modify it under the terms of the GNU Lesser General Public
00011 //    License as published by the Free Software Foundation; either
00012 //    version 2.1 of the License, or (at your option) any later version.
00013 //
00014 //    omniIFR is distributed in the hope that it will be useful,
00015 //    but WITHOUT ANY WARRANTY; without even the implied warranty of
00016 //    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00017 //    Lesser General Public License for more details.
00018 //
00019 //    You should have received a copy of the GNU Lesser General Public
00020 //    License along with this library; if not, write to the Free Software
00021 //    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00022 //
00023 #include "ExceptionDef.h"
00024 
00025 #include "Repository.h"
00026 #include "idltype.h"
00027 #include "PersistNode.h"
00028 
00029 namespace Omniifr {
00030 
00031 TypeCode_ptr ExceptionDef_impl::type()
00032 {
00033   return Repository_impl::inst()._orb
00034          ->create_exception_tc(_id.in(),_name.in(),_members.in());
00035 }
00036 
00037 StructMemberSeq* ExceptionDef_impl::members()
00038 {
00039   return _members.copy();
00040 }
00041 
00042 void ExceptionDef_impl::members(const StructMemberSeq& v)
00043 {
00044   checkReadonly();
00045   // Essentially this method is the same as StructDef_impl::members().
00046   // See that method for implementation notes.
00047   StructMemberSeq temp(v); // take a copy (v is const).
00048   for(ULong i=0; i<temp.length(); i++)
00049   {
00050     if(CORBA::is_nil(temp[i].type_def))
00051         throw CORBA::BAD_PARAM(
00052           IFELSE_OMNIORB4(omni::BAD_PARAM_InvalidObjectRef,43),
00053           CORBA::COMPLETED_NO
00054         );
00055     try {
00056         temp[i].type=temp[i].type_def->type();
00057     }
00058     catch(...) {
00059       DB(15,"Caught exception at "<<__FILE__<<":"<<__LINE__)
00060       throw; // If an exception occurs, just propagate it as-is.
00061     }
00062   }
00063 
00064   _members.assign(temp);
00065 }
00066 
00067 CORBA::Contained::Description* ExceptionDef_impl::describe()
00068 {
00069   ExceptionDescription_var desc =new ExceptionDescription();
00070   desc->name       = name();
00071   desc->id         = id();
00072   desc->defined_in = definedInId();
00073   desc->version    = version();
00074   desc->type       = type();
00075 
00076   CORBA::Contained::Description_var description =
00077     new CORBA::Contained::Description();
00078   description->kind  =   def_kind();
00079   description->value <<= desc._retn();
00080 
00081   return description._retn();
00082 }
00083 
00084 void ExceptionDef_impl::uncheckedDestroy()
00085 {
00086   _members.clear();
00087   Contained_impl::uncheckedDestroy();
00088   Container_impl::uncheckedDestroy();
00089 }
00090 
00091 bool ExceptionDef_impl::canContain(DefinitionKind kind)
00092 {
00093   switch(kind)
00094   {
00095     case dk_Struct:
00096     case dk_Union:
00097     case dk_Enum:
00098       return true;
00099     default:
00100       return false;
00101   }
00102 }
00103 
00104 void ExceptionDef_impl::reincarnate(const PersistNode& node)
00105 {
00106   cdrMemoryStream memstr =node.attrCdrStream("state");
00107   StructMemberSeq m;
00108   m<<=memstr;
00109   _members.uncheckedAssign(m); // Skip the checks performed by members(m)
00110 }
00111 
00112 void ExceptionDef_impl::output(ostream &os)
00113 {
00114   outputSelf(os,"ExceptionDef");
00115   cdrMemoryStream memstr(CORBA::ULong(0),CORBA::Boolean(1)/*clearMemory*/);
00116   _members.in()>>=memstr;
00117   PersistNode::outputCdrMemoryStream(os,memstr,"\n state=");
00118   os<<" ;;\n";
00119   outputContents(os);
00120 }
00121 
00122 } // end namespace Omniifr

Generated on Fri Mar 4 13:03:23 2005 for OmniIFR by  doxygen 1.4.1