#include #include #include //#include "phycas/phycas.h" #if defined(ALL_BIND_USING_CPPS_IN_ONE_FILE) # define INCLUDED_FROM_OTHER_BIND_USING_FILE # if defined(_MSC_VER) //#warning not allowed in VC7 # include "ncl/characters/nxs_characters_block.cpp" # include "ncl/command/nxs_command_output.cpp" # else # warning using macro to include nxs_charcters_block.cpp TEMPORARY HACK! # include "ncl/characters/nxs_characters_block.cpp" # warning using macro to include nxs_command_output.cpp TEMPORARY HACK! # include "ncl/command/nxs_command_output.cpp" # endif #endif #include "CipresIDL/api1/ReadNexus.hpp" #include "CipresIDL/api1/TreeImprove.hpp" #if defined(HAVE_OMNIORB4) && HAVE_OMNIORB4 # include "omniORB4/Naming.hh" #else # error "only omniORB is supported" #endif #include "boost/shared_ptr.hpp" using std::cout; using std::endl; using std::cerr; using std::string; class OrbWrapper { public: OrbWrapper(CORBA::ORB_var o); ~OrbWrapper(); CORBA::ORB_var orb; /// }; typedef boost::shared_ptr OrbWrapperShPtr; OrbWrapper::OrbWrapper(CORBA::ORB_var o) // CORBA::ORB_var appears to be pointer :orb(o) { orb = o; } OrbWrapper::~OrbWrapper() { orb->destroy (); } int main(int argc, char *argv[]) { # if defined(MONITORING_ALLOCATION) && !defined(NDEBUG) CREATE_MEMCHK { # endif try { string filename; OrbWrapperShPtr orbWrapperPtr; try { cerr << "ORB_init("; for (int i = 0 ; i < argc; ++i) cerr << argv[i] << ' '; cerr << ")\n"; orbWrapperPtr = OrbWrapperShPtr(new OrbWrapper(CORBA::ORB_init (argc, argv, "cipres_TAO_orb"))); //arbitrary orb name if (argc < 2) { cerr << "Expecting the filename of a NEXUS file with characters and a tree as an argument"; abort(); } filename = argv[1]; cout << "Filename = "<< filename << endl; } catch (const CORBA::Exception & ex) { cerr << "Could not initialize ORB" << endl; abort(); } CosNaming::NamingContext_var naming_context; try { // contact the NameService CORBA::Object_var naming_context_object = orbWrapperPtr->orb->resolve_initial_references ("NameService"); naming_context = CosNaming::NamingContext::_narrow (naming_context_object.in ()); cerr << "Got NameService" << endl; } catch(const CORBA::Exception & ex) { cerr << "Could not get the NameService" << endl; abort(); } CosNaming::Name name (1); name.length (1); CipresIDL_api1::ReadNexus_var nexusReader; try { name[0].id = CORBA::string_dup ("ReadNexus"); CORBA::Object_var rn_object = naming_context->resolve (name); nexusReader = CipresIDL_api1::ReadNexus::_narrow (rn_object.in ()); } catch (...) { cerr << "Could not get ReadNexus object reference"<resolve (name); treeImprover = CipresIDL_api1::TreeImprove::_narrow (ti_object.in ()); } catch (...) { cerr << "Could not get TreeImprove object reference"<readNexusFile(filename.c_str(), CipresIDL_api1::ReadNexus::NEXUS_TAXA_BLOCK_BIT | CipresIDL_api1::ReadNexus::NEXUS_TREES_BLOCK_BIT | CipresIDL_api1::ReadNexus::NEXUS_CHARACTERS_BLOCK_BIT); } catch (const CipresIDL_api1::NexusException &e) { cerr <<"Nexus Error on line "<< e.lineNumber <<":\n"<< e.errorMsg <length() < 3 || (*readBlocks)[CipresIDL_api1::ReadNexus::NEXUS_TREES_BLOCK_INDEX] < 1) { cerr << "Expecting to find a trees block in " << filename<getCharacters(0); if (!chars) { cerr << "No matrix obtained." <setMatrix(*chars); cout << "Getting trees from NexusReader" << endl; ::CipresIDL_api1::TreeSeq * trees = nexusReader->getTrees(0); if (!trees || trees->length() < 1) { cerr << "No trees obtained." <setTree((*trees)[0]); cout << "Calling improveTree" << endl; ::CipresIDL_api1::Tree * returnedTree = treeImprover->improveTree(CosEventChannelAdmin::ProxyPushConsumer::_nil()); if (!trees) { cerr << "No trees returned." <