1
//-----------------------------------------------------------------------------
2 // Copyright (c) 2013 GarageGames, LLC
4 // Permission is hereby granted, free of charge, to any person obtaining a copy
5 // of this software and associated documentation files (the "Software"), to
6 // deal in the Software without restriction, including without limitation the
7 // rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
8 // sell copies of the Software, and to permit persons to whom the Software is
9 // furnished to do so, subject to the following conditions:
11 // The above copyright notice and this permission notice shall be included in
12 // all copies or substantial portions of the Software.
14 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21 //-----------------------------------------------------------------------------
22 #include "console/engineAPI.h"
23 #include "moduleDefinition.h"
24 #include "moduleManager.h"
26 DefineEngineMethod(ModuleDefinition
, save
, bool, (),,
27 "Saves the module definition to the file it was loaded from (if any).\n"
28 "@return (bool success) Whether the module definition was saved or not.\n")
31 return object
->save();
34 //-----------------------------------------------------------------------------
36 DefineEngineMethod(ModuleDefinition
, getModuleManager
, S32
, (),,
37 "Gets the module manager which this module definition is registered with (if any).\n"
38 "@return (moduleManager) The module manager which this module definition is registered with (zero if not registered).\n")
40 // Fetch module manager.
41 ModuleManager
* pModuleManager
= object
->getModuleManager();
43 return pModuleManager
!= NULL
? pModuleManager
->getId() : 0;
46 //-----------------------------------------------------------------------------
48 DefineEngineMethod(ModuleDefinition
, getDependencyCount
, S32
, (), ,
49 "Gets the number of module dependencies this module definition has.\n"
50 "@return (int count) The number of module dependencies this module definition has.\n")
52 // Get module dependency count.
53 return object
->getDependencyCount();
56 //-----------------------------------------------------------------------------
58 DefineEngineMethod(ModuleDefinition
, getDependency
, String
, (U32 dependencyIndex
), (0),
59 "Gets the module dependency at the specified index.\n"
60 "@param dependencyIndex The module dependency index.\n"
61 "@return (module - dependency) The module dependency at the specified index.")
63 // Get module dependency.
64 ModuleDefinition::ModuleDependency dependency
;
65 if ( object
->getDependency( dependencyIndex
, dependency
) == false )
66 return StringTable
->EmptyString();
68 // Format module dependency.
69 char* pReturnBuffer
= Con::getReturnBuffer( 256 );
70 dSprintf( pReturnBuffer
, 256, "%s %d", dependency
.mModuleId
, dependency
.mVersionId
);
75 //-----------------------------------------------------------------------------
77 DefineEngineMethod(ModuleDefinition
, addDependency
, bool, (const char* pModuleId
, U32 versionId
), ("", 0),
78 "Adds the specified moduleId and vesionId as a dependency.\n"
79 "@param moduleId The module Id to add as a dependency.\n"
80 "@param versionId The version Id to add as a dependency. Using zero indicates any version."
81 "@return (bool success) Whether the module dependency was added or not.")
84 return object
->addDependency( pModuleId
, versionId
);
87 //-----------------------------------------------------------------------------
89 DefineEngineMethod(ModuleDefinition
, removeDependency
, bool, (const char* pModuleId
), (""),
90 "Removes the specified moduleId as a dependency.\n"
91 "@param moduleId The module Id to remove as a dependency.\n"
92 "@return (bool success) Whether the module dependency was removed or not.")
95 return object
->removeDependency( pModuleId
);