src/ai/api/ai_list.hpp
branchnoai
changeset 9589 2fbda08db406
parent 9584 fa45068a210b
child 9590 16cde7f36a88
equal deleted inserted replaced
9588:01b2435c977b 9589:2fbda08db406
   173 
   173 
   174 	/**
   174 	/**
   175 	 * The definition how valuators should look.
   175 	 * The definition how valuators should look.
   176 	 */
   176 	 */
   177 	class Valuator {
   177 	class Valuator {
       
   178 		friend class AIList;
   178 	public:
   179 	public:
   179 		virtual ~Valuator() {}
   180 		virtual ~Valuator() {}
   180 
   181 
   181 		virtual int32 Valuate(const int32 item) = 0;
   182 	private:
       
   183 		virtual int32 Valuate(int32 item) const = 0;
   182 	};
   184 	};
   183 
   185 
   184 	/**
   186 	/**
   185 	 * Give all items a value defined by the valuator you give.
   187 	 * Give all items a value defined by the valuator you give.
   186 	 * @note the valuator should be a valid instance.
   188 	 * @note the valuator should be a valid instance.
   187 	 */
   189 	 */
   188 	void Valuate(AIList::Valuator *proc);
   190 	void Valuate(const AIList::Valuator &proc);
   189 };
   191 };
   190 
   192 
   191 #ifdef DEFINE_SQUIRREL_CLASS
   193 #ifdef DEFINE_SQUIRREL_CLASS
   192 namespace SQConvert {
   194 namespace SQConvert {
   193 	/* Allow inner classes/structs to be used as Squirrel parameters */
   195 	/* Allow inner classes/structs to be used as Squirrel parameters */
   194 	template <> AIList::Valuator *GetParam(ForceType<AIList::Valuator *>, HSQUIRRELVM vm, int index) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return (AIList::Valuator *)instance; }
   196 	template <> const AIList::Valuator &GetParam(ForceType<const AIList::Valuator &>, HSQUIRRELVM vm, int index) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return *(AIList::Valuator *)instance; }
   195 
   197 
   196 	/* Allow AIList to be used as Squirrel parameter */
   198 	/* Allow AIList to be used as Squirrel parameter */
   197 	template <> AIList *GetParam(ForceType<AIList *>, HSQUIRRELVM vm, int index) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return (AIList *)instance; }
   199 	template <> AIList *GetParam(ForceType<AIList *>, HSQUIRRELVM vm, int index) { SQUserPointer instance; sq_getinstanceup(vm, index, &instance, 0); return (AIList *)instance; }
   198 }; // namespace SQConvert
   200 }; // namespace SQConvert
   199 
   201