<commit_before>/*
**  Copyright (C) 2012 <NAME>ics
**  See COPYING for the license
*/
#include <qitype/objecttypebuilder.hpp>
#include <boost/thread.hpp>
#include <qitype/genericobject.hpp>
#include "staticobjecttype.hpp"
#include "metaobject_p.hpp"

namespace qi {

  class ObjectTypeBuilderPrivate
  {
  public:
    ObjectTypeBuilderPrivate() : type(0)  {}
    ObjectTypeData data;
    ObjectType*    type;
    MetaObject     metaObject;
  };

  ObjectTypeBuilderBase::ObjectTypeBuilderBase()
  : _p(new ObjectTypeBuilderPrivate())
  {
  }

  ObjectTypeBuilderBase::~ObjectTypeBuilderBase()
  {
    delete _p;
  }

  int ObjectTypeBuilderBase::xAdvertiseMethod(const std::string &retsig, const std::string& signature, GenericMethod func, int id)
  {
    unsigned int nextId = _p->metaObject._p->addMethod(retsig, signature, id);
    _p->data.methodMap[nextId] = func;
    return nextId;
  }

  int ObjectTypeBuilderBase::xAdvertiseEvent(const std::string& signature, SignalMemberGetter getter, int id)
  {
    unsigned int nextId = _p->metaObject._p->addSignal(signature, id);
    _p->data.signalGetterMap[nextId] = getter;
    return nextId;
  }

  void ObjectTypeBuilderBase::xBuildFor(Type* type, boost::function<Manageable* (void*)> asManageable)
  {
    _p->data.asManageable = asManageable;
    _p->data.classType = type;
  }


  const MetaObject& ObjectTypeBuilderBase::metaObject()<commit_msg>ObjectTypeBuilder: screams when calling advertise* after type()<commit_after>/*
**  Copyright (C) 2012 <NAME>ics
**  See COPYING for the license
*/
#include <qitype/objecttypebuilder.hpp>
#include <boost/thread.hpp>
#include <qitype/genericobject.hpp>
#include "staticobjecttype.hpp"
#include "metaobject_p.hpp"

namespace qi {

  class ObjectTypeBuilderPrivate
  {
  public:
    ObjectTypeBuilderPrivate() : type(0)  {}
    ObjectTypeData data;
    ObjectType*    type;
    MetaObject     metaObject;
  };

  ObjectTypeBuilderBase::ObjectTypeBuilderBase()
  : _p(new ObjectTypeBuilderPrivate())
  {
  }

  ObjectTypeBuilderBase::~ObjectTypeBuilderBase()
  {
    delete _p;
  }

  int ObjectTypeBuilderBase::xAdvertiseMethod(const std::string &retsig, const std::string& signature, GenericMethod func, int id)
  {
    if (_p->type) {
      qiLogError("ObjectTypeBuilder") << "ObjectTypeBuilder: Can't call xAdvertiseMethod with method '"
                                      << retsig << " " << signature << "' because type is already created.";
      return -1;
    }
    unsigned int nextId = _p->metaObject._p->addMethod(retsig, signature, id);
    _p->data.methodMap[nextId] = func;
    return nextId;
  }

  int ObjectTypeBuilderBase::xAdvertiseEvent(const std::string& signature, SignalMemberGetter getter, int id)
  {
    if (_p->type) {
      qiLogError("ObjectTypeBuilder") << "ObjectTypeBuilder: Can't call xAdvertiseEvent with event '"
                                      << signature << "' because type is already created.";
      return -1;
    }
    unsigned int nextId = _p->metaObject._p->addSignal(signature, id);
    _p->data.signalGetterMap[nextId] = getter;
    return nextId;
  }

  void ObjectTypeBuilderBase::xBuildFor(Type* type, boost::function<Manageable* (void*)> asManageable)
  {
    _p->data.asManageable = asManageable;
    _p->data.classType = type;
  }


  const MetaObject& ObjectTypeBuilderBase::metaObject()
{'fraction_non_alphanumeric': 0.11943863839952225, 'fraction_numerical': 0.0035831591519856674, 'mean_word_length': 3.8976608187134505, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 31, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2941905', 'n_tokens_mistral': 1083, 'n_tokens_neox': 1053, 'n_words': 220}