File: FCDLibrary.hpp

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 (89 lines) | stat: -rw-r--r-- 2,238 bytes parent folder | download | duplicates (4)
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
/*
	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
*/

#ifndef _FCD_EXTRA_H_
#include "FCDocument/FCDExtra.h"
#endif // _FCD_EXTRA_H_
#ifndef _FCD_ASSET_H_
#include "FCDocument/FCDAsset.h"
#endif // _FCD_ASSET_H_
#ifndef _FCD_ENTITY_H_
#include "FCDocument/FCDEntity.h"
#endif // _FCD_ENITTY_H_

template <class T>
FCDLibrary<T>::FCDLibrary(FCDocument* document)
:	FCDObject(document)
,	InitializeParameterNoArg(entities)
,	InitializeParameterNoArg(extra)
,	InitializeParameterNoArg(asset)
{
	extra = new FCDExtra(document, this);
}

template <class T>
FCDLibrary<T>::~FCDLibrary()
{
	SAFE_RELEASE(extra);
	SAFE_RELEASE(asset);
}

// Create the asset if it isn't already there.
template <class T>
FCDAsset* FCDLibrary<T>::GetAsset(bool create)
{
	if (create && asset == NULL) asset = new FCDAsset(GetDocument());
	return asset;
}

// Search for the entity in this library with a given COLLADA id.
template <class T>
const T* FCDLibrary<T>::FindDaeId(const fm::string& daeId) const
{
#ifdef _DEBUG
	// [staylor] June 12 2007 - !!Code change verification check!!
	// When fixing up the FCPlugin archive merge, removed SkipPound
	// here (Should be obsolete).  If you see this code much past this 
	// date, feel free to remove it.
	FUAssert (daeId.empty() || daeId[0] != '#',);
#endif

	size_t entityCount = entities.size();
	for (size_t i = 0; i < entityCount; ++i)
	{
		const FCDEntity* found = entities[i]->FindDaeId(daeId);
		if (found != NULL && found->GetObjectType() == T::GetClassType())
		{
			return (T*) found;
		}
	}
	return NULL;
}

// Search for the entity in this library with a given COLLADA id.
template <class T>
T* FCDLibrary<T>::AddEntity()
{
	T* entity = new T(GetDocument());
	entities.push_back(entity);
	SetNewChildFlag();
	return entity;
}


template <class T>
void FCDLibrary<T>::AddEntity(T* entity) 
{ 
	entities.push_back(entity); SetNewChildFlag(); 
}