Skip to content

pghalliday/OOOCode-Repository

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

29 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

OOOCode-Repository

OOOCode Repository interface for retrieving named lumps of data.

OOOIRepository interface

  • Should support getting named data
  • Should support asynchronous implementations

Roadmap

  • Nothing yet

OOOCacheRepository

  • Should implement the OOOICache interface

Roadmap

  • Should support chaining to other OOOCacheRepository instances
  • Should cache data to the file system

Roadmap

  • Should implement a proxy repository to chain repositories that do not chain
  • Should implement an in band repository to load data from broadcast
  • Should implement a remote repository to load data from the network

API

To implement an OOOIRepository

MyRepository.h

#ifndef MyRepository_H
#define MyRepository_H

#include "OOOIRepository.h"

#define OOOClass MyRepository
OOODeclare()
    OOOImplements
        OOOImplement(OOOIRepository)
    OOOImplementsEnd
    OOOExports
    OOOExportsEnd
OOODeclareEnd
#undef OOOClass

#endif

MyRepository.c

#include "MyRepository.h"

#define OOOClass MyRepository

OOOPrivateData
OOOPrivateDataEnd

OOODestructor
{
}
OOODestructorEnd

OOOMethod(void, get, OOOIRepositoryData * iRepositoryData)
{
    unsigned char * pData;
    size_t uSize;
    char * szName = OOOICall(iRepositoryData, getName);

    /* TODO: Retrieve the data */

    /* Notify the cache data instance that caching is complete */
    OOOICall(iRepositoryData, data, NULL, pData, uSize);
}
OOOMethodEnd

OOOConstructor()
{
#define OOOInterface OOOIRepository
    OOOMapVirtuals
        OOOMapVirtual(get)
    OOOMapVirtualsEnd
#undef OOOInterface
}
OOOConstructorEnd

#undef OOOClass

To use OOOCacheRepository

#include "OOOCacheRepository.h"

OOOCacheRepository * pRepository;
unsigned char pMyData[] =
{
    ...
}
size_t uMySize = sizeof(pMyData);

/* Declare a private data class */

#define OOOClass MyPrivateData
OOODeclare(char * szName, unsigned char * pData, size_t uSize)
    OOOImplements
        OOOImplement(OOOICacheData)
        OOOImplement(OOOIRepositoryData)
    OOOImplementsEnd
    OOOExports
    OOOExportsEnd
OOODeclareEnd
#undef

static void start()
{
    MyPrivateData * pMyPrivateData = OOOConstruct(MyPrivateData, "Test", pMyData, uMySize);
    pRepository = OOOConstruct(OOOCacheRepository);
    OOOICall(OOOCast(OOOICache, pRepository), set, OOOCast(OOOICacheData, pMyPrivateData));
}

static void cached(MyPrivateData * pMyPrivateData, OOOIError * iError)
{
    assert(iError == NULL);
    OOOICall(OOOCast(OOOIRepository, pRepository), get, OOOCast(OOOIRepositoryData, pMyPrivateData));
}

static void data(MyPrivateData * pMyPrivateData, OOOIError * iError, unsigned char * pData, size_t uSize)
{
    OOODestroy(pMyPrivateData);

    assert(iError == NULL);
    assert(pData == pMyData);
    assert(uSize == uMySize);

    OOODestroy(pRepository);
}


/* Implement the private data class */

#define OOOClass MyPrivateData
OOOPrivateData
    char * szName;
    unsigned char * pData;
    size_t uSize;
OOOPrivateDataEnd

OOODestructor
OOODestructorEnd

OOOMethod(char *, getName)
    return OOOF(szName);
OOOMethodEnd

OOOMethod(unsigned char *, getData)
    return OOOF(pData);
OOOMethodEnd

OOOMethod(size_t, getSize)
    return OOOF(uSize);
OOOMethodEnd

OOOMethod(void, cached, OOOIError * iError)
    cached(OOOThis, iError);
OOOMethodEnd

OOOMethod(void, data, OOOIError * iError, unsigned char * pData, size_t uSize)
    data(OOOThis, iError, pData, uSize);
OOOMethodEnd

OOOConstructor(char * szName, unsigned char * pData, size_t uSize)
#define OOOInterface OOOICacheData
    OOOMapVirtuals
        OOOMapVirtual(getName)
        OOOMapVirtual(getData)
        OOOMapVirtual(getSize)
        OOOMapVirtual(cached)
    OOOMapVirtualsEnd
#undef OOOInterface

#define OOOInterface OOOIRepositoryData
    OOOMapVirtuals
        OOOMapVirtual(getName)
        OOOMapVirtual(data)
    OOOMapVirtualsEnd
#undef OOOInterface

    OOOMapMethods
    OOOMapMethodsEnd

    OOOF(szName) = szName;
    OOOF(pData) = pData;
    OOOF(uSize) = uSize;
OOOConstructorEnd
#undef OOOClass

Contributing

In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality.

Prerequisites

Initialising

This project references sub-modules so after cloning the repository...

git submodule init
git submodule update

Then the easiest way to work with the project in the OpenTV IDE...

  1. Create a new workspace in the root of the project
  2. In the IDE choose File/Import...
  3. In the resulting dialog choose General/Existing Projects Into Workspace and press Next
  4. Choose the Select Root Directory: Radio button and Browse... to the root of the project
  5. A number of projects may be listed under Projects
  6. Select the projects in the root, deselect those under the submodules folder and then click Finish
  7. You should then be able to build the OpenTV projects by choosing Project/Build All

After you have built the projects at least once run the test application in the Virtual Set top box by...

  1. Choosing the RepositoryFlow project on the left
  2. Pressing the green Run button at the top
  3. In the resulting dialog choose Local OpenTV Application and press OK

License

Copyright (c) 2012 Peter Halliday
Licensed under the MIT license.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors