Skip to content

Instantly share code, notes, and snippets.

@scopatz
Created March 21, 2014 02:15
Show Gist options
  • Save scopatz/9678197 to your computer and use it in GitHub Desktop.
Save scopatz/9678197 to your computer and use it in GitHub Desktop.
Ouch
virtual void InitFrom(StubFacility* m) {};
virtual void InitFrom(stubs::StubFacility* m) {
cyclus::Facility::InitFrom(m);
};
@scopatz
Copy link
Author

scopatz commented Mar 21, 2014

#ifndef CYCLUS_STUBS_STUB_FACILITY_H_
#define CYCLUS_STUBS_STUB_FACILITY_H_

#include <string>

#include "cyclus.h"

namespace stubs {

/**
  @class StubFacility

  This Facility is intended
  as a skeleton to guide the implementation of new Facility
  agents.
  The StubFacility class inherits from the Facility class and is
  dynamically loaded by the Agent class when requested.

  @section intro Introduction
  Place an introduction to the agent here.

  @section agentparams Agent Parameters
  Place a description of the required input parameters which define the
  agent implementation.

  @section optionalparams Optional Parameters
  Place a description of the optional input parameters to define the
  agent implementation.

  @section detailed Detailed Behavior
  Place a description of the detailed behavior of the agent. Consider
  describing the behavior at the tick and tock as well as the behavior
  upon sending and receiving materials and messages.
  */
class StubFacility : public cyclus::Facility  {
  /* --------------------
   * all FACILITYMODEL classes have these members
   * --------------------
   */
 public:
  /**
    Constructor for StubFacility Class
    @param ctx the cyclus context for access to simulation-wide parameters
    */
  explicit  StubFacility(cyclus::Context* ctx);

  /**
    every agent should be destructable
    */
  virtual ~StubFacility();

  virtual void InfileToDb(cyclus::InfileTree* qe, cyclus::DbInit di) {};

  virtual void InitInv(cyclus::Inventories& inv) {};
  virtual cyclus::Agent* Clone();

  virtual cyclus::Inventories SnapshotInv() {return cyclus::Inventories();}
  virtual void InitFrom(StubFacility* m) {};
  virtual void InitFrom(stubs::StubFacility* m) {
    cyclus::Facility::InitFrom(m);
  };

  virtual void InitFrom(cyclus::QueryableBackend* b) {
    cyclus::Facility::InitFrom(b);
    cyclus::QueryResult qr = b->Query("Info", NULL);
  };

  virtual void InfileToDb(cyclus::InfileTree* tree, cyclus::DbInit di) {
    cyclus::Facility::InfileToDb(tree, di);
    tree = tree->SubTree("agent/" + agent_impl());
    di.NewDatum("Info")
    ->Record();
  };

  virtual cyclus::Agent* Clone() {
    stubs::StubFacility* m = new stubs::StubFacility(context());
    m->InitFrom(this);
    return m;
  };

  virtual std::string schema() {
    return ""
      ;
  };

  virtual void Snapshot(cyclus::DbInit di) {
    di.NewDatum("Info")
    ->Record();
  };

  virtual void InitInv(cyclus::Inventories& inv) {
  };

  virtual cyclus::Inventories SnapshotInv() {
    cyclus::Inventories invs;
    return invs;
  };

  /**
    A verbose printer for the StubFacility
    */
  virtual std::string str();

  /**
    The handleTick function specific to the StubFacility.

    @param time the time of the tick
    */
  virtual void Tick(int time);

  /**
    The handleTick function specific to the StubFacility.

    @param time the time of the tock
    */
  virtual void Tock(int time);

  /* ------------------- */


  /* --------------------
   * _THIS_ FACILITYMODEL class has these members
   * --------------------
   */

  /* ------------------- */
};

}

#endif  // CYCLUS_STUBS_STUB_FACILITY_H_

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment