// ---------------------------------------------------------------------------
// - Libcsm.cpp                                                              -
// - afnix:csm service - declaration & implementation                        -
// ---------------------------------------------------------------------------
// - This program is free software;  you can redistribute it  and/or  modify -
// - it provided that this copyright notice is kept intact.                  -
// -                                                                         -
// - This program  is  distributed in  the hope  that it will be useful, but -
// - without  any  warranty;  without  even   the   implied    warranty   of -
// - merchantability or fitness for a particular purpose.  In no event shall -
// - the copyright holder be liable for any  direct, indirect, incidental or -
// - special damages arising in any way out of the use of this software.     -
// ---------------------------------------------------------------------------
// - copyright (c) 1999-2013 amaury darsch                                   -
// ---------------------------------------------------------------------------

#include "Ico.hpp"
#include "Meta.hpp"
#include "Libcsm.hpp"
#include "CartSet.hpp"
#include "Predcsm.hpp"
#include "Function.hpp"
#include "Assistant.hpp"
#include "SessionSet.hpp"
#include "LocalSpace.hpp"

namespace afnix {

  // initialize the afnix:csm service

  Object* init_afnix_csm (Interp* interp, Vector* argv) {
    // make sure we are not called from something crazy
    if (interp == nilp) return nilp;

    // create the afnix:csm nameset
    Nameset* aset = interp->mknset ("afnix");
    Nameset* gset = aset->mknset   ("csm");

    // bind all symbols in the afnix:csm nameset
    gset->symcst ("Rco",           new Meta (Rco::mknew));
    gset->symcst ("Ico",           new Meta (Ico::mknew));
    gset->symcst ("Slot",          new Meta (Slot::mknew));
    gset->symcst ("Cart",          new Meta (Cart::mknew));
    gset->symcst ("CartSet",       new Meta (CartSet::mknew));
    gset->symcst ("Session",       new Meta (Session::mknew));
    gset->symcst ("Appointer",     new Meta (Appointer::mknew));
    gset->symcst ("Assistant",     new Meta (Assistant::mknew));
    gset->symcst ("SessionSet",    new Meta (SessionSet::mknew));
    gset->symcst ("LocalSpace",    new Meta (LocalSpace::mknew));

    // bind the predicates
    gset->symcst ("rco-p",         new Function (csm_rcop));
    gset->symcst ("ico-p",         new Function (csm_icop));
    gset->symcst ("cart-p",        new Function (csm_cartp));
    gset->symcst ("slot-p",        new Function (csm_slotp));
    gset->symcst ("session-p",     new Function (csm_sessp));
    gset->symcst ("cart-set-p",    new Function (csm_csetp));
    gset->symcst ("appointer-p",   new Function (csm_apptp));
    gset->symcst ("workspace-p",   new Function (csm_wspcp));
    gset->symcst ("assistant-p",   new Function (csm_asstp));
    gset->symcst ("localspace-p",  new Function (csm_lspcp));
    gset->symcst ("session-set-p", new Function (csm_ssetp));

    // not used but needed
    return nilp;
  }
}

extern "C" {
  afnix::Object* dli_afnix_csm (afnix::Interp* interp, afnix::Vector* argv) {
    return init_afnix_csm (interp, argv);
  }
}
