⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 kr_object.h

📁 这是法国Kaleido公司提供了一个手机mmi设计平台
💻 H
📖 第 1 页 / 共 2 页
字号:
/***************************************************************************
KR_Object.h  -
--------------
begin                : Tue Mar 3 2004
copyright            : (C) 2004 by DigitalAirways
email                : info@digitalairways.com
***************************************************************************/

/*
* Copyright (c) 2000-2004 DigitalAirways, sarl. All Rights Reserved.
*
* This software is the confidential and proprietary information of
* DigitalAirways, sarl. ("Confidential Information").  You shall not
* disclose such Confidential Information and shall use it only in
* accordance with the terms of the license agreement you entered into
* with DigitalAirways.
* A copy of this license is included in the licence.txt file included
* in this software package.
*/

/*
**************************************************************
* TODO
**************************************************************

-



**************************************************************
* HISTORY
**************************************************************

-
*/

#ifndef __KR_Object__
#define __KR_Object__

#include "EB_Utils.h"
#include "SmallArrayList.h"

#undef remove /* To avoid any external dirty redefinition */

//#define GSHASH TRUE

class GContext ;

class KREBDLIBS_API Object {
private:
	GContext* gContext;
	void* fInstanciatorPtr;

public :
	DEFINE_NEW(Object);
	DEFINE_DELETE(Object);

	Object(GContext* newGContext){
		gContext = newGContext ;
	}

	virtual ~Object(){
	}

	void* getInstanciatorPtr() {
		return fInstanciatorPtr;
	}

	void setInstanciatorPtr(void* n) {
		fInstanciatorPtr=n;
	}


	virtual boolean equals(Object* o) {
		return o==this;
	}

	GContext* getContext() {
		return gContext;
	}

};

/*


//returns info associated to the given key

static Option* find (BigIntMap* map, long action) {

Option4ActionNode* current = (Option4ActionNode*)map->getFirst();

while (current != NULL) {
if (current->fAction != action)
current = (Option4ActionNode*)current->getNext();
else {
// found
return current->fOption;
}
}
// not found
return NULL;
}

*/

class KREBDLIBS_API LinkedListNode {

protected:
	LinkedListNode* fNext;

public:
	DEFINE_NEW(LinkedListNode);
	DEFINE_DELETE(LinkedListNode);

	LinkedListNode() {
		fNext = NULL;
	}

	LinkedListNode* getNext() {
		return fNext;
	}

	void setNext(LinkedListNode* v) {
		fNext = v;
	}

};

/**

*/
class LinkedList {

protected:
	LinkedListNode* first; //pointer to the first node of the list
	LinkedListNode* last;  //pointer to the last node of the list

public:
	DEFINE_NEW(LinkedList);
	DEFINE_DELETE(LinkedList);

	LinkedList() {
		first = NULL;
		last = NULL;
	}

	// by definition, SmallArrayList does NOT have ownership on the stored objects, thus does NOT delete them.
	// clear() only deletes nodes. What the node itself deletes depends on the destructor.
	virtual ~LinkedList() {
		clear();
	}


	/*
	<kaleidoc>
	<filename>LinkedList</filename>
	<page>
	<api><class>LinkedList</class>
	<method>getFirst</method>
	<java></java>
	<cpp>LinkedListNode* getFirst()</cpp>
	<descr>
	<p>Returns the first element of this list.
	LinkedList KEEPS ownership on the returned node.
	(LinkedList never had ownership of any node referenced object).</p>
	</descr>
	</api>
	</page>
	</kaleidoc>
	*/
	LinkedListNode* getFirst() {
		return first;
	}

	/*
	<kaleidoc>
	<filename>LinkedList</filename>
	<page>
	<api><class>LinkedList</class>
	<method>setFirst</method>
	<java></java>
	<cpp>void setFirst(LinkedListNode* newNode)</cpp>
	<descr>
	<p>Sets newNode as the first element.</p>
	</descr>
	</api>
	</page>
	</kaleidoc>
	*/
	void setFirst(LinkedListNode* newNode) {
		first=newNode;
	}


	/*
	<kaleidoc>
	<filename>LinkedList</filename>
	<page>
	<api><class>LinkedList</class>
	<method>addFirst</method>
	<java></java>
	<cpp>void addFirst(LinkedListNode* newNode);</cpp>
	<descr>
	<p>Appends the specified element to the begin of this list.
	LinkedList DOES take ownership of the given node and will delete it when not needed anymore.
	LinkedList does NOT take ownership of the referenced objects in the node.</p>
	</descr>
	</api>
	</page>
	</kaleidoc>
	*/
	void addFirst(LinkedListNode* newNode);

	/*
	<kaleidoc>
	<filename>LinkedList</filename>
	<page>
	<api><class>LinkedList</class>
	<method>size</method>
	<java></java>
	<cpp></cpp>
	<descr>
	<p>Returns the number of elements in this list.
	size() use a loop over all element: costs time.</p>
	</descr>
	</api>
	</page>
	</kaleidoc>
	*/
	int size();

	/*
	<kaleidoc>
	<filename>LinkedList</filename>
	<page>
	<api><class>LinkedList</class>
	<method>isEmptyList</method>
	<java></java>
	<cpp>boolean isEmptyList()</cpp>
	<descr>
	<p>Returns true if this list contains no elements.</p>
	</descr>
	</api>
	</page>
	</kaleidoc>
	*/
	boolean isEmptyList() const;

	/*
	<kaleidoc>
	<filename>LinkedList</filename>
	<page>
	<api><class>LinkedList</class>
	<method>clear</method>
	<java></java>
	<cpp>void clear()</cpp>
	<descr>
	<p>Removes all of the elements from this list.
	Referenced objects are not deleted.
	This list will be empty after this call returns. </p>
	</descr>
	</api>
	</page>
	</kaleidoc>
	*/
	void clear();


}; //. LinkedList.


class KREBDLIBS_API BigIntMapNode : public LinkedListNode {
public:
	long fKey;
	void* fValue;

	DEFINE_NEW(BigIntMapNode);
	DEFINE_DELETE(BigIntMapNode);

	BigIntMapNode() : LinkedListNode () {
		fKey=0;
		fValue=NULL;
	}

	// DEPRECATED BEGIN
	long getKey() {
		return fKey;
	}

	void* getValue() {
		return fValue;
	}
	// DEPRECATED END

};

class BigIntMap {

protected:
	LinkedList* fList;
	boolean	fAllowMultiple;

private:
	void init();
	void basicAdd(long key, void* value);

public:

	DEFINE_NEW(BigIntMap);
	DEFINE_DELETE(BigIntMap);
	/**
	Default constructor.
	*/
	BigIntMap();
	/**
	constructor providing the initial capacity to help allocate directly a good sized array in array based implementation.
	This implementation is based on linked list. Thus, initial capacity is not used.
	*/
	BigIntMap(long initialCapacity);
	/**
	*/
	virtual ~BigIntMap() ;
	/**
	return the nb of associated key,value.
	If allowMultiple, multiple values count for many in the size.
	*/
	long size();

	/**
	add value to the corresponding key. If allowMultiple and values are already registered for this key,
	the new value is registered also and preceding values are kept.
	if !allowMultiple, this call is equivalent to set.
	For efficientcy reasons, add does NOT check if the same (key, value) association is added more than one time.
	BigIntMap does NOT take ownership of the objet and will not delete it.
	*/
	void add(long key, void* value);

	/**
	Removes the first association (key, value) found from the map.
	If the same (key, value) association is added more than one time, only one of them will be removed.
	BigIntMap does NOT take ownership of the objet and will not delete it.
	*/
	void remove(long key, void* value);

	/**
	Removes all associations (key, value) found from the map, with the given key
	*/
	void remove(long key);

	/**
	Removes all mappings from this map.
	*/
	void clear();

	/**
	set value to the corresponding key.
	Returns the previous value, NULL if no previous value.
	If allowMultiple and there is many values corresponding to a key, all other associations are deleted.
	If allowMultiple, the previous value is of little use since the returned value comes from one but undefined association.
	BigIntMap does NOT take ownership of value and will not delete it: previous value is NOT deleted.
	*/
	void* set(long key, void* value);

	/**
	return the value associated to the corresponding key.
	BigIntMap didn't get ownership of the value.
	if allowMultiple, get returns the first value associated with key.
	Returns NULL if not found.
	*** ACTUALLY no way to gets others ***
	*/
	void* get(long key);

	/**
	Returns key associated to a value (forst value found). Values are compared by pointers.
	BigIntMap didn't get ownership of the value.
	Returns NULL if not found.
	*/
	long getKey(void* value);

	/**
	*/
	BigIntMapNode* getFirst();

	/**
	returns value number index. Poor performances for unit test only.
	Returns NULL if not found.
	*/
	void* getNValue(long index);

	/**
	true if the map should handle many values for the same key.
	false is the default.
	*/
	void setAllowMultiple(boolean v) {
		fAllowMultiple=v;
	}

	boolean allowMultiple() {
		return fAllowMultiple;
	}


}; //. BigIntMap

typedef BigIntMap Option4ActionMap;
typedef BigIntMap Option4AccessKeyMap;
typedef BigIntMap LinksJumpMap;

class StringBufferNode {

public:

	char* fString;
	boolean fOwnership;

	DEFINE_NEW(StringBufferNode);
	DEFINE_DELETE(StringBufferNode);

	// val may be null.
	StringBufferNode(char* val, boolean takeOwnership) {
		fString = val;
		fOwnership = takeOwnership;
	}

	~StringBufferNode(){
		if(fOwnership){
			SAFE_FREE(fString);
		}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -