File: FCDLibrary.h

package info (click to toggle)
0ad 0.0.23.1-2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 78,292 kB
  • sloc: cpp: 245,166; ansic: 200,249; python: 13,754; sh: 6,104; perl: 4,620; makefile: 977; xml: 810; java: 533; ruby: 229; erlang: 46; pascal: 30; sql: 21; tcl: 4
file content (126 lines) | stat: -rw-r--r-- 4,567 bytes parent folder | download | duplicates (16)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
/*
	Copyright (C) 2005-2007 Feeling Software Inc.
	Portions of the code are:
	Copyright (C) 2005-2007 Sony Computer Entertainment America
	
	MIT License: http://www.opensource.org/licenses/mit-license.php
*/
/*
	Based on the FS Import classes:
	Copyright (C) 2005-2006 Feeling Software Inc
	Copyright (C) 2005-2006 Autodesk Media Entertainment
	MIT License: http://www.opensource.org/licenses/mit-license.php
*/

/**
	@file FCDLibrary.h
	This file contains the FCDLibrary template class.
	See the FCDLibrary.hpp file for the template implementation.
*/

#ifndef _FCD_LIBRARY_
#define _FCD_LIBRARY_

#ifndef __FCD_OBJECT_H_
#include "FCDocument/FCDObject.h"
#endif // __FCD_OBJECT_H_
#ifndef _FU_PARAMETER_H_
#include "FUtils/FUParameter.h"
#endif // _FU_PARAMETER_H_

class FCDocument;
class FCDAsset;
class FCDEntity;
class FCDExtra;

/**
	A COLLADA library.

	A COLLADA library holds a list of entities. There are libraries for the following entities:
	animations (FCDAnimation), animation clips (FCDAnimationClip), meshes and splines (FCDGeometry),
	materials (FCDMaterial), effects (FCDEffect), images (FCDImage), skins and morphers (FCDController),
	cameras (FCDCamera), lights (FCDLight), physics models (FCDPhysicsModel), physics materials
	(FCDPhysicsMaterial), physics scenes (FCDPhysicsScene) and visual scenes (FCDSceneNode).

	The COLLADA libraries are contained within the FCDocument object.

	@ingroup FCDocument
*/	
template <class T>
class FCOLLADA_EXPORT FCDLibrary : public FCDObject
{
private:
	DeclareObjectType(FCDObject);

	/** Entities list. This list should contain all the root entities of the correct type.
		Note that the following entity types are tree-based, rather than list-based: FCDAnimation,
		FCDSceneNode and FCDPhysicsScene. */
	DeclareParameterContainer(T, entities, FC("Entities"));

	// Extra information for the entity.
	DeclareParameterRef(FCDExtra, extra, FC("Extra Tree"));

	// Asset information for the entity.
	DeclareParameterRef(FCDAsset, asset, FC("Asset Tag"));

public:
	/** Constructor: do not use directly.
		All the necessary libraries are created by the FCDocument object during its creation.
		@param document The parent document. */
	FCDLibrary(FCDocument* document);

	/** Destructor. */
	virtual ~FCDLibrary();

	/** Creates a new entity within this library.
		@return The newly created entity. */
	T* AddEntity();

	/** Inserts a new entity to this library.
		This function is useful if you are adding cloned entites
		back inside the library.
		@param entity The entity to insert in the library.
		@return The entity to insert. */
	void AddEntity(T* entity);

	/** Retrieves the library entity with the given COLLADA id.
		@param daeId The COLLADA id of the entity.
		@return The library entity which matches the COLLADA id.
			This pointer will be NULL if no matching entity was found. */
	T* FindDaeId(const fm::string& daeId) { return const_cast<T*>(const_cast<const FCDLibrary*>(this)->FindDaeId(daeId)); }
	const T* FindDaeId(const fm::string& daeId) const; /**< See above. */

	/** Returns whether the library contains no entities.
		@return Whether the library is empty. */
	inline bool IsEmpty() const { return entities.empty(); }

	/** Retrieves the number of entities within the library.
		@return the number of entities contained within the library. */
	inline size_t GetEntityCount() const { return entities.size(); }

	/** Retrieves an indexed entity from the library.
		@param index The index of the entity to retrieve.
			Should be within the range [0, GetEntityCount()[.
		@return The indexed entity. */
	inline T* GetEntity(size_t index) { FUAssert(index < GetEntityCount(), return NULL); return entities.at(index); }
	inline const T* GetEntity(size_t index) const { FUAssert(index < GetEntityCount(), return NULL); return entities.at(index); } /**< See above. */

	/** Retrieves the asset information for the library.
		The non-const version of this function can create
		an empty asset structure for this library.
		@param create Whether to create the asset tag if it is missing. Defaults to true.
		@return The asset tag for the library. */
	FCDAsset* GetAsset(bool create = true);
	inline const FCDAsset* GetAsset() const { return asset; } /** See above. */

	/** Retrieves the asset information for the library.
		@return The asset tag for the library. */
	inline FCDExtra* GetExtra() { return extra; }
	inline const FCDExtra* GetExtra() const { return extra; } /** See above. */
};

#ifdef __APPLE__
#include "FCDocument/FCDLibrary.hpp"
#endif // __APPLE__

#endif // _FCD_LIBRARY_