source: NonGTP/FCollada/FCDocument/FCDEffectCode.h @ 964

Revision 964, 4.0 KB checked in by igarcia, 19 years ago (diff)
RevLine 
[964]1/*
2        Copyright (C) 2005-2006 Feeling Software Inc.
3        MIT License: http://www.opensource.org/licenses/mit-license.php
4*/
5
6/**
7        @file FCDEffectCode.h
8        This file contains the FCDEffectCode class.
9*/
10
11#ifndef _FCD_EFFECT_CODE_H_
12#define _FCD_EFFECT_CODE_H_
13
14#include "FCDocument/FCDObject.h"
15
16class FCDocument;
17
18/**
19        A COLLADA code inclusion.
20
21        Code inclusions come in two forms: file includes and inline code.
22        For file includes, you will want to grab the filename of the file
23        using the GetFilename function and for inline code, you can get
24        the code directly through the GetCode function.
25
26        Code inclusions are referenced through sub-ids by the effect pass
27        shaders. Regardless of the extension of the filename of file
28        includes, the code inclusions' language is solely determined by
29        the effect profile they belong to.
30*/
31class FCDEffectCode : public FCDObject
32{
33public:
34        /** The list of support code inclusion types. */
35        enum Type
36        {
37                INCLUDE, /** A file include. @see GetFilename */
38                CODE /** Inlined code. @see GetCode */
39        };
40
41private:
42        DeclareObjectType;
43
44        Type type;
45        string sid;
46        fstring code;
47        fstring filename;
48
49public:
50        /** Constructor: do not use directly.
51                Instead, use the FCDEffectProfile::AddCode
52                or the FCDEffectTechnique::AddCode functions.
53                @param document The COLLADA document that owns this code inclusion. */
54        FCDEffectCode(FCDocument* document);
55
56        /** Destructor: do not use directly.
57                Instead, use the FCDEffectProfile::ReleaseCode
58                or the FCDEffectTechnique::ReleaseCode functions. */
59        ~FCDEffectCode();
60
61        /** Retrieves the form of the code inclusion.
62                @return The form. */
63        inline Type GetType() const { return type; }
64
65        /** Sets the form of the code inclusion.
66                Changing the form of the code inclusion will not
67                remove the inline code or the filename.
68                @param _type The form. */
69        inline void SetType(Type _type) { type = _type; }
70
71        /** Retrieves the sub-id of the code inclusion.
72                Used to match the code inclusion within the effect pass shaders.
73                @return The sub-id. */
74        const string& GetSid() const { return sid; }
75
76        /** Sets the sub-id of the code inclusion.
77                This value may change on export, as the sub-id must be unique within its scope.
78                @param _sid The sub-id. */
79        void SetSid(const string& _sid) { sid = _sid; }
80
81        /** Retrieves the inlined code.
82                First verify that this code inclusion contains inlined code
83                using the GetType function.
84                @return The inlined code. */
85        const fstring& GetCode() const { return code; }
86
87        /** Sets the inlined code.
88                As a side-effect, calling this function forces the type of the code inclusion.
89                @param _code The inlined code. */
90        void SetCode(const fstring& _code) { code = _code; type = CODE; }
91
92        /** Retrieves the filename of the code file to open.
93                First verify that this code inclusion contains a filename
94                using the GetType function.
95                @return The code filename. */
96        const fstring& GetFilename() const { return filename; }
97
98        /** Sets the filename of the code file.
99                As a side-effect, calling this function forces the type of the code inclusion.
100                @param _filename The code filename. */
101        void SetFilename(const fstring& _filename) { filename = _filename; type = INCLUDE; }
102
103        /** [INTERNAL] Clones the code inclusion.
104                @return The cloned effect object. You will must delete this pointer. */
105        FCDEffectCode* Clone() const;
106
107        /** [INTERNAL] Reads in the code inclusion from a given COLLADA XML tree node.
108                Code inclusions cover the \<code\> element and the \<include\> element.
109                @param codeNode The COLLADA XML tree node.
110                @return The status of the import. If the status is not successful,
111                        it may be dangerous to extract information from the code inclusion.*/
112        FUStatus LoadFromXML(xmlNode* codeNode);
113
114        /** [INTERNAL] Writes out the code inclusion to the given COLLADA XML tree node.
115                @param parentNode The COLLADA XML parent node in which to insert the code inclusion.
116                @return The created element XML tree node. */
117        xmlNode* WriteToXML(xmlNode* parentNode) const;
118};
119
120#endif // _FCD_EFFECT_CODE_H_
Note: See TracBrowser for help on using the repository browser.