#ifndef _COS_LIFE_CYCLE_IDL_
#define _COS_LIFE_CYCLE_IDL_

#include <CosNaming.idl>

#pragma prefix "omg.org"

module CosLifeCycle{

	typedef CosNaming::Name Key; 
	typedef Object _Factory;
	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 {		
		boolean _supports(in Key k);
		Object create_object(			
				in Key 			k, 
				in Criteria		the_criteria) 				
			raises (NoFactory, InvalidCriteria, 										
				CannotMeetCriteria);
	};
};
#endif /* ifndef _COS_LIFE_CYCLE_IDL_ */
