Skip to content

Commit

Permalink
api_generator: c++ refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
genywind committed Dec 29, 2012
1 parent 97f1139 commit cc3b8a9
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 24 deletions.
2 changes: 1 addition & 1 deletion platform/shared/api_generator/common/MethodResult.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class CMethodResult
{
rho::Hashtable<rho::String, rho::String> resHash;
resHash.put( m_strStringParam, m_strRes);
set(resHash);
m_hashStrRes = resHash; m_ResType = eStringHash;
}
}

Expand Down
43 changes: 25 additions & 18 deletions platform/shared/api_generator/sample/windows/Barcode1.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,33 +42,17 @@ class CBarcode1ImplBase: public IBarcode1

};

class CBarcode1
class CBarcode1FactoryBase
{
protected:
static rho::String m_strDefaultID;
static rho::Hashtable<rho::String,IBarcode1*> m_hashBarcodes;
static rho::common::CAutoPtr<rho::common::CThreadQueue> m_pCommandQueue;

public:
static IBarcode1* create(const rho::String& strID);
static rho::Hashtable<rho::String,IBarcode1*>& getBarcodes(){ return m_hashBarcodes; }

static rho::String getDefaultID()
{
if ( m_strDefaultID.length() == 0 )
CBarcode1::initDefaultID();

if ( !getBarcodes().containsKey(m_strDefaultID) )
{
IBarcode1* pObj = create(m_strDefaultID);
getBarcodes().put(m_strDefaultID, pObj );
}
return m_strDefaultID;
}

static void setDefaultID(const rho::String& strDefaultID){ m_strDefaultID = strDefaultID; }
static void initDefaultID();

static void enumerate(CMethodResult& oResult);

static void setCommandQueue( rho::common::CThreadQueue* pQueue){ m_pCommandQueue = pQueue; }
static void addCommandToQueue(rho::common::IRhoRunnable* pFunctor)
Expand All @@ -81,4 +65,27 @@ class CBarcode1

m_pCommandQueue->addQueueCommand( new CGeneratorQueue::CGeneratorQueueCommand(pFunctor) );
}
};

class CBarcode1 : public CBarcode1FactoryBase
{
public:
static IBarcode1* create(const rho::String& strID);
static void initDefaultID();
static void enumerate(CMethodResult& oResult);


static rho::String getDefaultID()
{
if ( m_strDefaultID.length() == 0 )
CBarcode1::initDefaultID();

if ( !getBarcodes().containsKey(m_strDefaultID) )
{
IBarcode1* pObj = create(m_strDefaultID);
getBarcodes().put(m_strDefaultID, pObj );
}
return m_strDefaultID;
}

};
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#include "Barcode1.h"

rho::Hashtable<rho::String,IBarcode1*> CBarcode1FactoryBase::m_hashBarcodes;
rho::String CBarcode1FactoryBase::m_strDefaultID;
rho::common::CAutoPtr<rho::common::CThreadQueue> CBarcode1FactoryBase::m_pCommandQueue;
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@

#include "ext/rho/rhoruby.h"

rho::Hashtable<rho::String,IBarcode1*> CBarcode1::m_hashBarcodes;
rho::String CBarcode1::m_strDefaultID;
rho::common::CAutoPtr<rho::common::CThreadQueue> CBarcode1::m_pCommandQueue;

extern "C"
{

Expand Down
6 changes: 5 additions & 1 deletion platform/shared/common/RhodesApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1235,7 +1235,11 @@ static void callback_is_blob_attr(void *arg, String const &strQuery)
rho_http_sendresponse(arg, "ok");
}


void CRhodesApp::registerLocalServerUrl(const String& strUrl, rho::net::CHttpServer::callback_t const &callback)
{
if ( m_httpServer )
m_httpServer->register_uri(strUrl.c_str(), callback);
}

void CRhodesApp::initHttpServer()
{
Expand Down

0 comments on commit cc3b8a9

Please sign in to comment.