//File: CosLifeCycle.idl
//Part of the LifeCycle Service
// Note: if your IDL compiler does not yet support the 
//   CORBA 2.3 Feature "Escaped Identifiers" (which provides 
//   for the addition of new keywords to IDL, compile this 
//   module with the preprocessor definition 
//   "NO_ESCAPED_IDENTIFIERS". With many compilers this 
//   would be done a qualifier on the command line, 
//   something like -DNO_ESCAPED_IDENTIFIERS

#ifndef _COS_LIFE_CYCLE_IDL_
#define _COS_LIFE_CYCLE_IDL_

// omniORB specific pragmas to insert extra includes into the stub header.
#pragma hh #include "COS_sysdep.h"

#include <CosNaming.idl>

#pragma prefix "omg.org"

module CosLifeCycle{

	typedef CosNaming::Name Key; 
#ifdef __OMNIIDL__
	typedef Object _Factory;
#else
	typedef Object Factory;
#endif
	typedef sequence <Factory> Factories;
	typedef struct NVP {	 
		CosNaming::Istring	name; 
		any 				value; 
	} NameValuePair;
	typedef sequence <NameValuePair> Criteria;

	exception NoFactory {
		Key search_key;
	};
	exception NotCopyable { string reason; };
	exception NotMovable { string reason; };
	exception NotRemovable { string reason; };
	exception InvalidCriteria{ Criteria invalid_criteria; };
	exception CannotMeetCriteria { Criteria unmet_criteria;	};

	interface FactoryFinder {
		Factories find_factories(in Key factory_key)
			raises(NoFactory);
	};

	interface LifeCycleObject {
		LifeCycleObject copy(in FactoryFinder there, 
							 in Criteria the_criteria)
			raises(NoFactory, NotCopyable, InvalidCriteria,
				 CannotMeetCriteria);
		void move(in FactoryFinder there, 
				  in Criteria the_criteria)
			raises(NoFactory, NotMovable, InvalidCriteria,
				 CannotMeetCriteria);
		void remove()
			raises(NotRemovable);
	};

	interface GenericFactory {		
#ifdef NO_ESCAPED_IDENTIFIERS
		boolean supports(in Key k);
#else
		boolean _supports(in Key k);
#endif
		Object create_object(			
				in Key 			k, 
				in Criteria		the_criteria) 				
			raises (NoFactory, InvalidCriteria, 										
				CannotMeetCriteria);
	};
};
#endif /* ifndef _COS_LIFE_CYCLE_IDL_ */
