mirror of
https://github.com/amyinspace/MagicSetEditor2.git
synced 2026-06-10 04:57:00 -04:00
Switched to a new coding style, which plays nicely with the Reader/Writer. This new style allows REFLECT to be used instead of REFLECT_N in most places.
git-svn-id: svn://svn.code.sf.net/p/magicseteditor/code/trunk@15 0fc631ac-6414-0410-93d0-97cfa31319b6
This commit is contained in:
@@ -214,7 +214,7 @@ COLLABORATION_GRAPH = NO
|
||||
GROUP_GRAPHS = YES
|
||||
UML_LOOK = NO
|
||||
TEMPLATE_RELATIONS = YES
|
||||
INCLUDE_GRAPH = YES
|
||||
INCLUDE_GRAPH = NO
|
||||
INCLUDED_BY_GRAPH = YES
|
||||
CALL_GRAPH = NO
|
||||
CALLER_GRAPH = NO
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
/** @page coding_conventions Coding conventions
|
||||
|
||||
MSE uses the following coding style:
|
||||
@code
|
||||
/// Doxygen documentation
|
||||
class ClassName {
|
||||
public:
|
||||
void someMemberFunction();
|
||||
private:
|
||||
int some_member; ///< postfix doxygen documentation
|
||||
};
|
||||
|
||||
void a_global_function();
|
||||
|
||||
enum MyEnumeration
|
||||
{ MY_SOMETHING
|
||||
, MY_SOMETHING_ELSE
|
||||
};
|
||||
@endcode
|
||||
|
||||
The rules are:
|
||||
- Classes use CaptializationForEachWord
|
||||
- Member functions use camelCase
|
||||
- Data members and globals use lower_case_with_underscores
|
||||
- Constants (enumeration values) and macros are UPPER_CASE_WITH_UNDERSCORES
|
||||
|
||||
The exceptions to this are:
|
||||
- wxWidgets functions, which LookLikeThis
|
||||
- wxWidget classes, which look like wxSomeClass
|
||||
- C++ standard library and boost, lower_case for everything
|
||||
- Person names, in particular deCasteljau
|
||||
- Class names in function names, in particular clearDC
|
||||
|
||||
|
||||
*/
|
||||
+25
-106
@@ -1,21 +1,35 @@
|
||||
/** \mainpage
|
||||
/** @mainpage
|
||||
|
||||
This is the documentation of the Magic Set Editor (MSE) source code, automatically generated using doxygen.
|
||||
|
||||
<h2>Structure</h2>
|
||||
Before starting with the source code, you should take a look at the following:
|
||||
- \subpage structure "Structure of the MSE source code"
|
||||
- \subpage dependencies "Libraries and dependencies"
|
||||
- \subpage coding_conventions "Coding conventions"
|
||||
- \subpage tricks "Tricks used by MSE"
|
||||
|
||||
|
||||
@page structure Structure of the MSE source code
|
||||
|
||||
The MSE source code is subdivided into several directories, with the following meaning:
|
||||
- util: Utility functions and classes, stuff that would work equally well in another project
|
||||
- gfx: Graphics related functions, again mostly independent of MSE.
|
||||
This directory contains algorithms for image blending, scaling, and bezier curve functions.
|
||||
- data: Data structures, like sets, cards, symbols, etc.
|
||||
These data structures are documented in the <a href="http://magicseteditor.sourceforge.net/extending">'Extending MSE'</a> section of the official documentation.
|
||||
- data/action: Actions that can be applied to those data structures.
|
||||
- gui: Graphical User Interface
|
||||
- resource: Resource files used (icons, cursors, etc.)
|
||||
- <tt>util</tt>: Utility functions and classes, stuff that would work equally well in another project
|
||||
- <tt>util/io</tt>: Classes related to input and output
|
||||
- <tt>gfx</tt>: Graphics related functions, again mostly independent of MSE.
|
||||
This directory contains algorithms for image blending, scaling, and bezier curve functions.
|
||||
- <tt>data</tt>: Data structures, like sets, cards, symbols, etc.
|
||||
These data structures are documented in the <a href="http://magicseteditor.sourceforge.net/extending">'Extending MSE'</a> section of the official documentation.
|
||||
- <tt>data/action</tt>: Actions that can be applied to those data structures.
|
||||
- <tt>data/field</tt>: Data types for fields, values and styles. One source file per type.
|
||||
- <tt>data/format</tt>: File formats and import/export stuff.
|
||||
- <tt>script</tt>: The scripting system.
|
||||
- <tt>gui</tt>: Graphical User Interface
|
||||
- <tt>set</tt>: SetWindow related
|
||||
- <tt>symbol</tt>: SymbolWindow related
|
||||
- <tt>resource</tt>: Resource files used (icons, cursors, etc.)
|
||||
|
||||
See <a href="dirs.html">the directory list</a> for details.
|
||||
|
||||
<h2>Libraries/dependencies</h2>
|
||||
@page dependencies Libraries and dependencies
|
||||
|
||||
MSE depends on the following libraries:
|
||||
- <a href="http://wxwidgets.org">wxWidgets</a> for the GUI.
|
||||
@@ -25,99 +39,4 @@ Additional tools (not needed for building MSE) also depend on:
|
||||
- <a href="http://doxygen.org">doxygen</a> for generating the documentation.
|
||||
- Perl for small utility scripts
|
||||
|
||||
|
||||
<h2>Coding style</h2>
|
||||
|
||||
MSE uses the following coding style:
|
||||
@code
|
||||
class ClassName {
|
||||
public:
|
||||
void someFunction();
|
||||
private:
|
||||
int someMember;
|
||||
};
|
||||
@endcode
|
||||
|
||||
The exception to this rule are wxWidgets functions, which LookLikeThis; and classes, which look like wxSomeClass.
|
||||
As well as standard library functions.
|
||||
|
||||
|
||||
<h2>Macro and template tricks</h2>
|
||||
|
||||
The source code uses several macro/preprocessor and template tricks to make the code more readable.
|
||||
|
||||
<h3>Smart pointers</h3>
|
||||
|
||||
MSE makes extensive use of boost::shared_ptr. To make the code more readable there are typedefs for these pointer types, using a suffix P.
|
||||
These are defined using a macro:
|
||||
@code
|
||||
DECLARE_POINTER_TYPE(MyClass);
|
||||
MyClassP someObject; // the same as boost::shared_ptr<MyClass> someObject
|
||||
@endcode
|
||||
|
||||
To create new shared_ptrs the function new_shared# can be used (where # is the number of arguments):
|
||||
@code
|
||||
MyClassP someObject;
|
||||
someObject = new_shared2<MyClass>(arg1, arg2);
|
||||
@endcode
|
||||
|
||||
Implemented in: util/smart_ptr.hpp
|
||||
|
||||
<h3>Iterating</h3>
|
||||
|
||||
To iterate over containers the FOR_EACH macro is used:
|
||||
@code
|
||||
vector<CardP> cards;
|
||||
FOR_EACH(card, cards) {
|
||||
doSomething(card);
|
||||
}
|
||||
@endcode
|
||||
Is equivalent to:
|
||||
@code
|
||||
vector<CardP> cards;
|
||||
for(vector<CardP>::iterator it = cards.begin() ; it != cards.end() ; ++it) {
|
||||
CardP& card = *it;
|
||||
doSomething(card);
|
||||
}
|
||||
@endcode
|
||||
The iterators are completely hidden!
|
||||
There are several veriations to this macro, for using const iterators (FOR_EACH_CONST), iterating in reverse (FOR_EACH_REVERSE),
|
||||
for iterating over two collections in parallel (FOR_EACH_2), and for getting access to the iterator (FOR_EACH_IT).
|
||||
|
||||
Each of these macros require that the collection type has been declared using:
|
||||
@code
|
||||
DECLARE_COLLECTION_TYPE(CardP);
|
||||
@endcode
|
||||
This allows the calling of TYPEOF(cards) to evaluate to vector<CardP>.
|
||||
|
||||
Implemented in: util/for_each.hpp
|
||||
|
||||
<h3>Reflection</h3>
|
||||
|
||||
The io (input/output) system is based on reflection.
|
||||
For a class to support reflection the following must be declared:
|
||||
@code
|
||||
class SomeClass {
|
||||
int member1, member2;
|
||||
DECLARE_REFLECTION();
|
||||
};
|
||||
@endcode
|
||||
Then in a source file the members of the class have to be specified:
|
||||
@code
|
||||
IMPLEMENT_REFLECTION(SomeClass) {
|
||||
REFLECT(member1);
|
||||
REFLECT_N("another_name", member2);
|
||||
}
|
||||
@endcode
|
||||
|
||||
Simlairly for enumerations (a declaration is not necessary):
|
||||
@code
|
||||
IMPLEMENT_REFLECTION_ENUM(MyEnum) {
|
||||
VALUE(value_of_enum_1); // the default value
|
||||
VALUE(value_of_enum_2);
|
||||
}
|
||||
@endcode
|
||||
|
||||
Implemented in: util/reflect.hpp
|
||||
|
||||
*/
|
||||
@@ -0,0 +1,86 @@
|
||||
/** @page tricks Macro and template tricks
|
||||
|
||||
The source code uses several macro/preprocessor and template tricks to make the code more readable.
|
||||
|
||||
<h2>Smart pointers</h2>
|
||||
|
||||
MSE makes extensive use of boost::shared_ptr. To make the code more readable there are typedefs for these pointer types, using a suffix P.
|
||||
These are defined using a macro:
|
||||
@code
|
||||
DECLARE_POINTER_TYPE(MyClass);
|
||||
MyClassP someObject; // the same as boost::shared_ptr<MyClass> someObject
|
||||
@endcode
|
||||
|
||||
To create new shared_ptrs the function new_shared# can be used (where # is the number of arguments):
|
||||
@code
|
||||
MyClassP someObject;
|
||||
someObject = new_shared2<MyClass>(arg1, arg2);
|
||||
@endcode
|
||||
|
||||
Implemented in: util/smart_ptr.hpp
|
||||
|
||||
|
||||
<h2>Iterating</h2>
|
||||
|
||||
To iterate over containers the FOR_EACH macro is used:
|
||||
@code
|
||||
vector<CardP> cards;
|
||||
FOR_EACH(card, cards) {
|
||||
doSomething(card);
|
||||
}
|
||||
@endcode
|
||||
Is equivalent to:
|
||||
@code
|
||||
vector<CardP> cards;
|
||||
for(vector<CardP>::iterator it = cards.begin() ; it != cards.end() ; ++it) {
|
||||
CardP& card = *it;
|
||||
doSomething(card);
|
||||
}
|
||||
@endcode
|
||||
The iterators are completely hidden!
|
||||
There are several veriations to this macro, for using const iterators (FOR_EACH_CONST), iterating in reverse (FOR_EACH_REVERSE),
|
||||
for iterating over two collections in parallel (FOR_EACH_2), and for getting access to the iterator (FOR_EACH_IT).
|
||||
|
||||
Each of these macros require that the collection type has been declared using:
|
||||
@code
|
||||
DECLARE_COLLECTION_TYPE(CardP);
|
||||
@endcode
|
||||
This allows the calling of TYPEOF(cards) to evaluate to vector<CardP>.
|
||||
|
||||
Implemented in: util/for_each.hpp
|
||||
|
||||
|
||||
<h2>Reflection</h2>
|
||||
|
||||
The io (input/output) system is based on reflection.
|
||||
For a class to support reflection the following must be declared:
|
||||
@code
|
||||
class SomeClass {
|
||||
int member1, member2;
|
||||
DECLARE_REFLECTION();
|
||||
};
|
||||
@endcode
|
||||
Then in a source file the members of the class have to be specified:
|
||||
@code
|
||||
IMPLEMENT_REFLECTION(SomeClass) {
|
||||
REFLECT(member1);
|
||||
REFLECT_N("another_name", member2);
|
||||
}
|
||||
@endcode
|
||||
|
||||
Simlairly for enumerations (a declaration is not necessary):
|
||||
@code
|
||||
IMPLEMENT_REFLECTION_ENUM(MyEnum) {
|
||||
VALUE_N("value1", MY_VALUE1); // the first is the default value
|
||||
VALUE_N("value2", MY_VALUE2);
|
||||
}
|
||||
@endcode
|
||||
|
||||
Reflection is used by the following classes:
|
||||
- Reader
|
||||
- Writer
|
||||
- GetMember
|
||||
|
||||
Implemented in: util/reflect.hpp
|
||||
|
||||
*/
|
||||
Reference in New Issue
Block a user