Explanation of the Code Base

From PCGen Wiki
Revision as of 08:12, 9 September 2012 by Masaru20100 (talk | contribs) (pcgen.gui)
Jump to: navigation, search

High level overview of PCGen Code Base

src/java/pcgen is where the code tree begins. The directories match the package names — so pcgen.core would be src/java/pcgen/core (or src\java\pcgen\core if you are on Windows).

Packages

pcgen.base.*

These classes are 'base' library elements. None of these should be objects that are dependent upon pcgen.cdom or pcgen.core classes. The intent is that pcgen.base elements are usable in any project, not specifically PCGen. No item which is deeply tied to the concept of a Role-Playing Game or building a Player Character should be present in this package.

pcgen.cdom.*

The pcgen.cdom package contains the core contents of the CDOM structure. There are a number of key subpackages of pcgen.cdom:

  1. pcgen.cdom.base: This is the "base" package, which has many key components that the entire PCGen code base is dependent upon. It should be expected that the members of this package have few dependencies outside of pcgen.base* and pcgen.cdom.base*, as this is "low" in the package hierarchy.
  2. pcgen.cdom.choiceset: This package contains Primitive Choice Sets
  3. pcgen.cdom.content: This package contains the non-CDOM Object content objects that would make up a Player Character. Long term, these objects would be "granted" by CDOM Objects, and thus would appear directly in the CDOM Graph that defines the Player Character (in 5.16, there is very little that distinguishes content from a helper)
  4. pcgen.cdom.enumeration: This package contains type safe enumerations (such as enums)
  5. pcgen.cdom.formula: This package contains items related to formula calculations performed by PCGen.
  6. pcgen.cdom.helper: This package is for "helper" objects of the CDOM Objects found within pcgen.cdom.inst. Generally a "helper" would be contained within the CDOM Object.
  7. pcgen.cdom.inst: This package is for instances of CDOM Objects. Long term, this will contain many of the objects currently in pcgen.core
  8. pcgen.cdom.list: This package contains list objects, such as Class Spell List objects. These list objects serve as identifiers for collections of CDOM Objects that are used at runtime.
  9. pcgen.cdom.reference: This package contains CDOM References
  10. pcgen.cdom.modifier: This package contains modifiers, a specialized form of content that is designed to alter the behavior of content that is part of a Player Character (The override from a Hit Die Lock is a good example of a modifier)
  11. pcgen.cdom.util: These are utility packages for classes contained within the pcgen.cdom* packages.

pcgen.rules.*

This package contains the classes related to the "Rules Data Store". The classes here are responsible for loading (and writing) the rules files (PCC, LST), and when combined with the token plugins, this package converts the persistent objects into the instances, lists, content, helpers, references, and other objects of the pcgen.cdom* package.

pcgen.core

This is where the business logic goes. This is the main engine that makes things work. The most important class in here is PObject, many classes are subclassed from this (like PCClass, Race, Feat, Spell, etc.). Another important class is PlayerCharacter which is where the player characters are constructed and manipulated. Globals contains the lists of objects loaded when a user loads their desired sources. Constants holds most of the code constants so you do not need to remember their values.

pcgen.gui

This is the GUI logic. The main method is in pcGenGUI, and the frame is in PCGen_Frame1. The editors are all defined in the editor package, and all the tab frames are in the tabs package. This is deprecated in favor of pcgen.gui2 classes.

pcgen.gui2

This is the NewGUI logic.

pcgen.io

This is where the disk writing stuff occurs, like creating/parsing pcg files, and exporting character sheets.

pcgen.persistence

This is where the lst files are read in. The class that controls the loading is SystemLoader.

pcgen.util

This is where generally useful classes that are don't fit any of the other categories go.

plugin

This is where the pluggable features go. This includes tools such as Character Sheet, Dicebag, Random Name Generator, Encounter Generator, Network Management, Experience Tracker, Initiative Tracker, GM Notes, Overland Travel and the Character Tracker. It also includes processors for the variety of Lst Tokens and Output Tokens. There is also an Architectural Discussion of the PCGen Persistence Plugin System to help provide additional explanation of how the Lst Tokens work.

See the Javadocs for further details of the PCGen code base.