newspeoplefor developersdocumentationdownloads

nPersistServer Class Reference
[Nebula Kernel]

#include <npersistserver.h>

Inheritance diagram for nPersistServer:

nRoot nObject nNode nReferenced nSignalEmitter List of all members.

Detailed Description

Interface to the file system for serializing objects.

See also nPersistServer Script Interface

Nebula Persistent Object File Format

The actual format of serialized objects is not specified. Instead script server objects are used to translate nCmd objects emitted by objects into actual script statements that will be saved to files. However, since the file server needs to know which script server to use for reading serialized object files, there has to be some meta information in the file itself which names the class of the script server which understands it.

Within the first 128 Bytes of a serialized object file the following string must be embedded:

    $parser:classname$
    

Where 'classname' is the script server's class which has to be used to read that file.

Folded and unfolded objects

Note:
UNFOLDED OBJECTS ARE NO LONGER SUPPORTED FOR WRITING, AND READING IS ONLY SUPPORTED FOR "FLAT" FILE HIERARCHIES (i.e. a "nKernelServer::Load("bla.n") is allowed if bla.n is a directory, and contains a _main file).
Serialized objects can be saved in 2 ways, folded and unfolded. Folded means, the object itself and all of it's children will be saved into a single file. Unfolded means that for each object, a directory will be create in the host filesystem, so that a saved object hierarchy will result in a corresponding directory hierarchy.

Code

The following code demonstrates how to specify nluaserver for persist server:

    nPersistServer* persisitServer;

    persisitServer = nKernelServer::Instance()->GetPersistServer();
    persisitServer->SetSaverClass("nluaserver");

(C) 2002 A.Weissflog

Definition at line 71 of file npersistserver.h.


Public Types

enum  nSaveMode {
  SAVEMODE_FOLD,
  SAVEMODE_CLONE
}
 Save modes. More...

Public Member Functions

 nPersistServer ()
 constructor
virtual ~nPersistServer ()
 destructor
void SetSaveMode (nSaveMode)
 set the save mode
nSaveMode GetSaveMode ()
 get the save mode
void SetSaveLevel (int)
 set the save level
int GetSaveLevel ()
 get the save level
bool SetSaverClass (const nString &saverClass)
 set the script server class which should be used for saving
nString GetSaverClass ()
 get the script server class which is currently used for saving
bool BeginObject (nObject *obj, const char *name, bool isObjNamed)
 begin a persistent object
bool BeginObjectWithCmd (nRoot *obj, nCmd *cmd, const char *name)
 begin a persistent object with constructor command
nCmdGetCmd (nObject *obj, nFourCC id)
 create a nCmd object
bool PutCmd (nCmd *cmd)
 put a cmd into persistency stream
bool PutCmd (int level, nCmd *cmd)
 put a cmd into persistency stream if savelevel permits
bool EndObject (bool isObjNamed)
 finish a persistent object
nObjectGetClone ()
 return cloned object
nObjectLoadObject (const char *fileName, const char *objName)
 load a object from persistency stream

Member Enumeration Documentation

enum nPersistServer::nSaveMode
 

Save modes.

Enumerator:
SAVEMODE_FOLD 
SAVEMODE_CLONE  default mode

Definition at line 75 of file npersistserver.h.


Constructor & Destructor Documentation

nPersistServer::nPersistServer  ) 
 

constructor

Definition at line 14 of file npersistserver_main.cc.

nPersistServer::~nPersistServer  )  [virtual]
 

destructor

Definition at line 28 of file npersistserver_main.cc.


Member Function Documentation

void nPersistServer::SetSaveMode nSaveMode   ) 
 

set the save mode

nPersistServer::nSaveMode nPersistServer::GetSaveMode  ) 
 

get the save mode

  • 05-Nov-98 floh created

Definition at line 301 of file npersistserver_main.cc.

void nPersistServer::SetSaveLevel int   ) 
 

set the save level

Definition at line 37 of file npersistserver_main.cc.

int nPersistServer::GetSaveLevel  ) 
 

get the save level

Definition at line 46 of file npersistserver_main.cc.

bool nPersistServer::SetSaverClass const nString saverClass  ) 
 

set the script server class which should be used for saving

Set class of script server which should be used to save objects. Creates a local script server object if not exists.

Parameters:
saverClass name of a nScriptServer derived class
Returns:
currently always true, breaks if object could not be created

Definition at line 60 of file npersistserver_main.cc.

nString nPersistServer::GetSaverClass  ) 
 

get the script server class which is currently used for saving

Get name of class which is currently used to save objects.

Definition at line 93 of file npersistserver_main.cc.

bool nPersistServer::BeginObject nObject obj,
const char *  name,
bool  isObjNamed
 

begin a persistent object

  • 04-Nov-98 floh created
  • 05-Nov-98 floh autonome Objects gekillt
  • 18-Dec-98 floh + SAVEMODE_CLONE
  • 09-Nov-04 enlight + nObject support

Definition at line 141 of file npersistserver_main.cc.

bool nPersistServer::BeginObjectWithCmd nRoot obj,
nCmd cmd,
const char *  name
 

begin a persistent object with constructor command

Start writing object, with constructor cmd instead of a generic "new [class] [name]". If cmd pointer is NULL, no constructor statement will be written, just the select statement.

  • 29-Feb-00 floh created

Definition at line 166 of file npersistserver_main.cc.

nCmd * nPersistServer::GetCmd nObject obj,
nFourCC  id
 

create a nCmd object

  • 04-Nov-98 floh created
  • 19-Dec-98 floh neues Arg, id + jetzt doch etwas komplexer, sucht das Command selbst raus, indem es die Klassen des Objekts durchsucht
  • 08-Aug-99 floh + benutzt nicht mehr nCmdProto::GetCmd(), sondern nCmdProto::NewCmd()

Definition at line 220 of file npersistserver_main.cc.

bool nPersistServer::PutCmd nCmd cmd  ) 
 

put a cmd into persistency stream

This is the same as a PutCmd(0,cmd).

  • 04-Nov-98 floh created
  • 08-Aug-99 floh nCmd wird nicht mehr per delete(), sondern per Cmd-Proto freigegeben
  • 20-Jan-00 floh rewritten to ref_ss

Definition at line 281 of file npersistserver_main.cc.

bool nPersistServer::PutCmd int  level,
nCmd cmd
 

put a cmd into persistency stream if savelevel permits

Ignore if level is less or equal the internal save level defined by 'SetSaveLevel'.

  • 16-Jun-00 floh created

Definition at line 250 of file npersistserver_main.cc.

bool nPersistServer::EndObject bool  isObjNamed  ) 
 

finish a persistent object

  • 04-Nov-98 floh created
  • 05-Nov-98 floh autonome Objects gekillt
  • 18-Dec-98 floh + SAVEMODE_CLONE
  • 09-Nov-04 enlight + nObject support

Definition at line 194 of file npersistserver_main.cc.

nObject * nPersistServer::GetClone  ) 
 

return cloned object

Get the pointer to the cloned object.

  • 18-Dec-98 floh created
  • 08-Nov-04 enlight now returns nObject* instead of nRoot*

Definition at line 260 of file npersistserver_beginend.cc.

nObject * nPersistServer::LoadObject const char *  fileName,
const char *  objName
 

load a object from persistency stream

Definition at line 160 of file npersistserver_load.cc.


The documentation for this class was generated from the following files:

Copyright © 1999-2005 by the contributing authors. Ideas, requests, problems: Send feedback.