assetQuery.h

Engine/source/assets/assetQuery.h

More...

Classes:

Public Defines

define
define

Detailed Description

Public Defines

ASSETQUERY_ASSETID_FIELD_NAME() "AssetId"
ASSETQUERY_ASSETNODE_NAME() "Asset"
ASSETQUERY_RESULTS_NODE_NAME() "Results"
 1
 2//-----------------------------------------------------------------------------
 3// Copyright (c) 2013 GarageGames, LLC
 4//
 5// Permission is hereby granted, free of charge, to any person obtaining a copy
 6// of this software and associated documentation files (the "Software"), to
 7// deal in the Software without restriction, including without limitation the
 8// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
 9// sell copies of the Software, and to permit persons to whom the Software is
10// furnished to do so, subject to the following conditions:
11//
12// The above copyright notice and this permission notice shall be included in
13// all copies or substantial portions of the Software.
14//
15// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21// IN THE SOFTWARE.
22//-----------------------------------------------------------------------------
23
24#ifndef _ASSET_QUERY_H_
25#define _ASSET_QUERY_H_
26
27#ifndef _SIMBASE_H_
28#include "console/simBase.h"
29#endif
30
31#ifndef _TVECTOR_H_
32#include "core/util/tVector.h"
33#endif
34
35#ifndef _STRINGUNIT_H_
36#include "core/strings/stringUnit.h"
37#endif
38
39#ifndef _TAML_CUSTOM_H_
40#include "persistence/taml/tamlCustom.h"
41#endif
42
43//-----------------------------------------------------------------------------
44
45#define ASSETQUERY_RESULTS_NODE_NAME     "Results"
46#define ASSETQUERY_ASSETNODE_NAME        "Asset"
47#define ASSETQUERY_ASSETID_FIELD_NAME   "AssetId"
48
49//-----------------------------------------------------------------------------
50
51class AssetQuery : public SimObject 
52{
53private:
54    typedef SimObject Parent;
55
56protected:
57    virtual void onTamlCustomWrite( TamlCustomNodes& customNodes );
58    virtual void onTamlCustomRead( const TamlCustomNodes& customNodes );
59
60    static const char* getCount(void* obj, const char* data) { return Con::getIntArg(static_cast<AssetQuery*>(obj)->mAssetList.size()); }
61    static bool writeCount( void* obj, StringTableEntry pFieldName ) { return false; }
62
63public:
64    AssetQuery() {}
65    virtual ~AssetQuery() {}
66
67    /// SimObject overrides
68    static void initPersistFields();
69
70    Vector<StringTableEntry> mAssetList;
71
72    /// Whether asset is contained or not.
73    inline bool containsAsset( StringTableEntry assetId )
74    {
75       for (Vector<StringTableEntry>::const_iterator assetItr = mAssetList.begin(); assetItr != mAssetList.end(); ++assetItr)
76        {
77            if ( *assetItr == assetId )
78                return true;
79        }
80        return false;
81    }
82
83    /// Set assets.
84    inline void set( const AssetQuery& assetQuery ) { this->mAssetList = assetQuery.mAssetList; }
85
86    /// Declare Console Object.
87    DECLARE_CONOBJECT( AssetQuery );
88};
89
90#endif // _ASSET_QUERY_H_
91
92