Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

问题 #1

Open
duxiwei opened this issue Jan 17, 2017 · 2 comments
Open

问题 #1

duxiwei opened this issue Jan 17, 2017 · 2 comments

Comments

@duxiwei
Copy link

duxiwei commented Jan 17, 2017

这不是动态库??

@same4869
Copy link
Owner

静态库自己用ndk编成的动态库

@Louanna
Copy link

Louanna commented Jun 1, 2017

Help,请帮忙看个问题:

android通过jni调用静态库,jni中如下调用:
NavContext navContext = NavContext(320,480);

编译通过了,运行报错 error: calling a private constructor of class 'Navionics::NavContext' NavContext如下:
#ifndef NAVCONTEXT_H
#define NAVCONTEXT_H

#include
#include
#include <stdlib.h>

// forward declarations of Navionics types in order to avoid propogation of .h
extern "C"
{
struct MapDirectory2_tag;
struct MapContext2_tag;
struct ResourceContext2_tag;
struct ViewCorners_tag;
struct tag_BPTable;
struct ap_chartconfig_tag;
}

namespace Navionics
{
// forward declarations
class NavApContext;
class NavBPContext;
class NavDamContext;
class NavChartData;

//! @enum file_type 
//! Describes the list of cartographic data files
enum	file_type
{
	NONE_FILE_TYPE = -1,
	NV2_FILE_TYPE = 0,
	PP_FILE_TYPE,
	PSG_FILE_TYPE,
	UGD_FILE_TYPE,
	S57_FILE_TYPE,
	BP_FILE_TYPE,
	BP2_FILE_TYPE,
	BP3_FILE_TYPE,
	AP_FILE_TYPE,
	MAX_FILE_TYPE
};

#define MAX_XF2_FILE_TYPE	5 //NV2, PP, PSG, UGD, S57
#define MAX_BP_FILE_TYPE	3 //NV2-bp, BP2, BP3

//! @enum DataOrigin 
//! specify the origin of the data to be loaded
//! in order to allow priority of chart data selection.
//! The priority will be in the following order:\n
//! - base map
//! - network hard drive dataset\n
//! - hard drive dataset\n
//! - network removable drive dataset\n
//! - removable drive dataset\n
enum DataOrigin
{
	//! Base map data
	DATAORIGIN_BASEMAP=0,
	//! Data mounted from network hard drive
	DATAORIGIN_NETWORK_HARDDRIVE,
	//! Data mounted from hard drive
	DATAORIGIN_HARDDRIVE,
	//! Data mounted from network removable drive
	DATAORIGIN_NETWORK_REMOVABLEDRIVE,
	//! Data mounted from removable drive
	DATAORIGIN_REMOVABLEDRIVE,
	//! Number of data origin (must be last)
	DATAORIGIN_NUM
};

//Macros below has been kept only for backward compatibility.
// Their usage is deprecated.
// NOTE: used for tune active BP tables number; to be reviewed
#define MIN_ACTIVE_CACHES 1
#define MAX_ACTIVE_CACHES_DEFAULT 4
#define MAX_ACTIVE_CACHES 8

///////////////////////////////////////////////////////////////////////////////
//! @Class NavContext
//! NavContext is a wrapper class of all geocore contextes that are needed
//! to handle Navionics charts (both for retreiving and drawing purposes).
//! The application must just create a NavContext object using one of the
//! two constructors and provide such object to NavChart and NavDraw classes.
//!
///////////////////////////////////////////////////////////////////////////////
class NavContext
{
friend class NavChart;
friend class NavDraw;
friend class NavDrawDam;

public:
	//! @enum CacheType
	//! Specify how much cache must be used
	//! by an instance of NavContext object.
	enum CacheType
	{
		//! It allocates about 113KB per active cache
		CACHE_TYPE_MINIMAL = 0,
		//! It allocates about 412KB per active cache
		CACHE_TYPE_NORMAL,
		//! It allocates about 2.3MB per active cache
		CACHE_TYPE_EXTREME
	};

	class BpContextSlotT
	{
		friend class NavContext;

		public:
			BpContextSlotT(void) : slotID(-1)
			{
				for (unsigned int i = 0; i < MAX_BP_FILE_TYPE; ++i)
				{
					pBpContext[i] = NULL;
				}
			};

			int GetSlotId(void) const { return slotID; };

			NavBPContext* GetContext(file_type inFileType) const
			{
				switch (inFileType)
				{
					case BP_FILE_TYPE:
						return pBpContext[0];

					case BP2_FILE_TYPE:
						return pBpContext[1];

					case BP3_FILE_TYPE:
						return pBpContext[2];

					default:
						return NULL;
				}
			};

		private:
			NavBPContext* pBpContext[MAX_BP_FILE_TYPE];
			int           slotID;
	};

	class ApContextSlotT
	{
		friend class NavContext;

		public:
			ApContextSlotT(void) : mChartID(-1)
			                     , mEBSA(0xffffffff)
			                     , mEBEA(0xffffffff)
			{
			};

			void GetData(ap_chartconfig_tag& outData) const;

		private:
			//! @property mEBSA
			//! Encryption block start address
			unsigned int mEBSA;
			//! @property mEBEA
			//! Encryption block end address
			unsigned int mEBEA;

			int          mChartID;
	};

	typedef std::vector<BpContextSlotT> BpContextListT;
	typedef std::vector<ApContextSlotT> ApContextListT;

	NavContext();
	NavContext(int inWidth, int inHeight);

	//The constructor below is deprecated.
	NavContext(int inWidth, int inHeight,
	           unsigned int inMaxActiveCache,
	           CacheType inCacheType = CACHE_TYPE_NORMAL);

	~NavContext(void);

	int Width(void) { return mWidth; };
	int Height(void) { return mHeight; };
	int ViewWidth(void) { return mViewWidth; };
	int ViewHeight(void) { return mViewHeight; };

	// Given a slot identifier (inSlotId parameter, returned by 
	// AddChart method call) it returns the associated chart handle 
	// of the specified inFileType.
	int GetChartHandle(int inSlotId, file_type inFileType);

	      bool                  GetMapDirectoryList (       file_type           inFileType, 
	                                                  const ViewCorners_tag*    pReqExtents,
	                                                        int                 inMinZoomLevel,
	                                                        int                 inMaxZoomLevel,
	                                                        MapDirectory2_tag*& outMapDirList,
	                                                        unsigned int&       outMapDirSize,
	                                                        bool                inSkipTiles = false);
	const MapDirectory2_tag*    GetMapDirectory    (int inSlotId, file_type inFileType);
	const ViewCorners_tag*      GetChartExtents    (int inSlotId, file_type inFileType);
	      MapContext2_tag*      GetMapContext      (void);
	      ResourceContext2_tag* GetResourceContext    (int inChartHandle);
	      void                  ReleaseResourceContext(int inChartHandle);

	      bool                  GetBpContextList (      int              inSiteID,
	                                              const ViewCorners_tag* pReqExtents,
	                                                    int              ReqZoomLevel,
	                                                    BpContextListT&  outBpCtxList);
	      bool                  GetBpContextList (const ViewCorners_tag* pReqExtents,
	                                                    int              ReqZoomLevel,
	                                                    BpContextListT&  outBpCtxList);
	      tag_BPTable*          GetBPTable       (int inSlotId, file_type inFileType);

	      bool                  GetApContextList (const ViewCorners_tag* pReqExtents,
	                                                    int              inMinZoomLevel,
	                                                    int              inMaxZoomLevel,
	                                                    ApContextListT&  outApCtxList);

	// Set and Get functions for Fishing Data flag
	bool SetFishingDataFlag(bool inFlag) 
	{
		if (mFishingDataFlag != inFlag)
		{
			mFishingDataFlag = inFlag;
			return true;
		}

		return false;
	};

	bool GetFishingDataFlag(void) { return mFishingDataFlag; };

	// Set and Get functions for S57 Data flag
	bool SetS57DataFlag(bool inFlag)
	{
		if (mS57DataFlag != inFlag)
		{
			mS57DataFlag = inFlag;
			return true;
		}
	
		return false;
	};

	bool GetS57DataFlag(void) { return mS57DataFlag; };

	// \TODO implement a mechanism to lock the NavContext. 

private:
	//! @class NavChartSlot
	//! Contains information about each slot owned by 
	//! an instance of NavContext class. For instance, chart identifier
	//! used by ReadByte call-back and relevant context (see NavChartData).
	//! Each slot contain reference to NavChartData instance allocated once 
	//! by NavChart class.
	class NavChartSlot
	{
		public:
			NavChartSlot(NavChartData* inOwnedChartData)
				: mOwnedChartData(inOwnedChartData)
			{
				for (unsigned int i = 0; i < MAX_FILE_TYPE; ++i)
					mChartIDs[i] = -1;
			};

			// Copy Constructor
			NavChartSlot(const NavChartSlot& theObject)
				: mOwnedChartData(theObject.mOwnedChartData)
			{
				for (unsigned int i = 0; i < MAX_FILE_TYPE; ++i)
					mChartIDs[i] = theObject.mChartIDs[i];
			};

			bool SetChartID(file_type index, int inChartID)
			{
				if (index >= MAX_FILE_TYPE)
					return false;

				mChartIDs[index] = inChartID;

				return true;
			};

			int GetChartID(file_type index)
			{
				if (index <= NONE_FILE_TYPE || index >= MAX_FILE_TYPE)
					return -1;

				return mChartIDs[index];
			};

			NavChartData* GetChartData(void)
			{
				return mOwnedChartData;
			};

		private:
			// Assignment Operator - is not allowed
			NavChartSlot& operator = (const NavChartSlot& theObject);

			NavChartData* mOwnedChartData;
			int           mChartIDs[MAX_FILE_TYPE];
	};

	// Represent the list of chart data slots owned by each NavContext.
	// Key : the slot identifier
	// Data: an instance of NavChartSlot class
	typedef std::map<int, NavChartSlot>            NavChartSlotMapT;
	typedef NavChartSlotMapT::iterator             NavChartSlotMapT_Iter;
	typedef std::pair<int, NavChartSlot>           NavChartSlotPairT;
	typedef std::pair<NavChartSlotMapT_Iter, bool> NavChartSlotPairT_Iter;

	//! @property mXF2MapDirArray
	//! Internal variables to return list of map directories compatible 
	//! with geoware libraries function calls
	MapDirectory2_tag*    mXF2MapDirArray;

	//! @property mXF2MapDirCapacity
	//! Internal variables to return list of map directories compatible 
	//! with geoware libraries function calls
	unsigned int          mXF2MapDirCapacity;

	//! @property mMapContext
	//! Map context used as temporary variable by all objects/threads
	//! that needs to retrieve cartographic data of a specific map.
	//! This includes NV2, NV3, PP and PSG maps. 
	//! NOTE: Is up to the caller to properly initialize the map 
	//! context before to use it.
	MapContext2_tag*      mMapContext;

	//! @property mResourceContext
	//! Resource contexts list used as temporary variable by all objects/threads
	//! that needs to retrieve cartographic data of a specific map.
	//! This includes NV2, PP and PSG maps. 
	//! NOTE: Is up to the caller to properly initialize the resource 
	//! context before to use it.
	ResourceContext2_tag** mResourceContext;
	int                    mLastResourceLoaded;

	//! @property mBpTable
	//! Pointer to a blue page table which stores all 
	//! required information in order to retrieve cartographic 
	//! data of BP section within either NV2 or NV3, BP2 or BP3 chart file
	tag_BPTable**          mBpTable;
	int                    mLastBpTableLoaded;

	//! @property mOwnedSlotIDs
	//! Vector of slot identifiers owned by this context.
	//! NOTE: The same slot of charts can be added by
	//! multiple threads hence we need to register
	//! the set of slot identifiers owned by each 
	//! NavContext object.
	NavChartSlotMapT      mOwnedSlotIDs;

	//! @property mMaxActiveBPtables
	//! Max number of active BP tables for this context.
	//! Valid range is [1..8].
	unsigned int          mMaxActiveBPtables;
	//! @property mViewWidth
	//! Width expressed in pixels of the view area of 
	//! the application.
	int mViewWidth;

	//! @property mViewHeight
	//! Height expressed in pixels of the view area of 
	//! the application.
	int mViewHeight;

	//! @property mWidth
	//! Width expressed in pixels of the memory area used
	//! to render and/or to query cartographic data 
	int mWidth;

	//! @property mHeight
	//! Height expressed in pixels of the memory area used
	//! to render and/or to query cartographic data 
	int mHeight;

	//! @property mFishingDataFlag
	//! Flag to enable or disable Fish & Chip datasets
	bool mFishingDataFlag;

	//! @property mS57DataFlag
	//! Flag to enable or disable S57 datasets
	bool mS57DataFlag;

	//! @property mNavDamContext
	NavDamContext* mNavDamContext;

	//! @property mDamContextInitialized.
	//! It specifies if the inner NavDamContext has been created or not.
	bool mDamContextInitialized;

	static bool SetBPGrphMode(tag_BPTable* pBpTable);

	// Copy Constructor - is not allowed
	NavContext(const NavContext& theObject);

	// Assignment Operator - is not allowed
	NavContext& operator = (const NavContext& theObject);

	// Used to resize the context when rotation is enabled
	void Resize(int inWidth, int inHeight, bool inResizeAll = false)
	{
		mWidth  = inWidth;
		mHeight = inHeight;
		if (inResizeAll)
		{
			mViewWidth = mWidth;
			mViewHeight = mHeight;
		}
	};

	tag_BPTable*  SetupBPTable(const NavBPContext* inBpContext,
	                                 int           inChartId);

	void                    AddSlot     (int inSlotId, NavChartSlot& inChartSlot);
	NavChartSlot&           GetSlot     (int inSlotId);
	void                    ReleaseSlot (int inSlotId);
	bool                    InvalidateMap(int inSlotId, file_type inFileType, int inMapID);

	void					InitDamContext();

	void					DeinitDamContext();

};

} // End namespace

#endif // NAVCONTEXT_H

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants