///////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////
//@file  fexibleconverterComp.cpp
//brief: 任意ポートを生成し変換を行うコンバーターコンポーネント
//$Date$ 2009/12/13
//@author eno 
//@mail:enoreplies@gmail.com
//@WebPage:http://www15.atpages.jp/~technotes/wiki/
//$Id$ 
///////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////
/*
fexibleconverter

The MIT License

Copyright (c) 2009 eno <enoreplies@gmail.com>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
/////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////


#include <rtm/Manager.h>
#include <iostream>
#include <string>
#include "flexibleconverter.h"


void MyModuleInit(RTC::Manager* manager)
{
	flexibleconverterInit(manager);
	RTC::RtcBase* comp;

	// Create a component
	comp = manager->createComponent("flexibleconverter");


	// Example
	// The following procedure is examples how handle RT-Components.
	// These should not be in this function.

	// Get the component's object reference
	//  RTC::RTObject_var rtobj;
	//  rtobj = RTC::RTObject::_narrow(manager->getPOA()->servant_to_reference(comp));

	// Get the port list of the component
	//  PortList* portlist;
	//  portlist = rtobj->get_ports();

	// getting port profiles
	//  std::cout << "Number of Ports: ";
	//  std::cout << portlist->length() << std::endl << std::endl; 
	//  for (CORBA::ULong i(0), n(portlist->length()); i < n; ++i)
	//  {
	//    Port_ptr port;
	//    port = (*portlist)[i];
	//    std::cout << "Port" << i << " (name): ";
	//    std::cout << port->get_port_profile()->name << std::endl;
	//    
	//    RTC::PortInterfaceProfileList iflist;
	//    iflist = port->get_port_profile()->interfaces;
	//    std::cout << "---interfaces---" << std::endl;
	//    for (CORBA::ULong i(0), n(iflist.length()); i < n; ++i)
	//    {
	//      std::cout << "I/F name: ";
	//      std::cout << iflist[i].instance_name << std::endl;
	//      std::cout << "I/F type: ";
	//      std::cout << iflist[i].type_name << std::endl;
	//      const char* pol;
	//      pol = iflist[i].polarity == 0 ? "PROVIDED" : "REQUIRED";
	//      std::cout << "Polarity: " << pol << std::endl;
	//    }
	//    std::cout << "---properties---" << std::endl;
	//    NVUtil::dump(port->get_port_profile()->properties);
	//    std::cout << "----------------" << std::endl << std::endl;
	//  }

	return;
}

int main (int argc, char** argv)
{
	RTC::Manager* manager;
	manager = RTC::Manager::init(argc, argv);

	// Initialize manager
	manager->init(argc, argv);

	// Set module initialization proceduer
	// This procedure will be invoked in activateManager() function.
	manager->setModuleInitProc(MyModuleInit);

	// Activate manager and register to naming service
	manager->activateManager();

	// run the manager in blocking mode
	// runManager(false) is the default.
	manager->runManager();

	// If you want to run the manager in non-blocking mode, do like this
	// manager->runManager(true);

	return 0;
}

